add lightwave parser

This commit is contained in:
2023-05-09 19:04:50 +02:00
parent 09a1e9ac0b
commit 48d3004c35
22 changed files with 667 additions and 13 deletions

View File

@@ -0,0 +1,46 @@
use binrw::{binread, BinRead};
use std::ops::Deref;
#[binread]
#[derive(Debug)]
pub struct Chunk<D>
where
for<'a> D: BinRead<Args<'a> = (u32,)>,
{
pub length: u32,
#[br(pad_size_to = length, align_after = 2, args(length))]
pub data: D,
}
impl<D> Deref for Chunk<D>
where
for<'a> D: BinRead<Args<'a> = (u32,)>,
{
type Target = D;
fn deref(&self) -> &Self::Target {
&self.data
}
}
#[binread]
#[derive(Debug)]
pub struct SubChunk<D>
where
for<'a> D: BinRead<Args<'a> = (u32,)>,
{
pub length: u16,
#[br(pad_size_to = length, align_after = 2, args(length as u32))]
pub data: D,
}
impl<D> Deref for SubChunk<D>
where
for<'a> D: BinRead<Args<'a> = (u32,)>,
{
type Target = D;
fn deref(&self) -> &Self::Target {
&self.data
}
}