project-wormhole-esm 0.1.0

ESM file format parser for Project Wormhole
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::dev::*;


// ====================================================================================================

// Keyword list uses two fields, a count and then a list of FormIDs to bypass the size limit of fields
pub struct KeywordList(pub Vec<FormId>);

impl Parse<&[u8]> for KeywordList {
    fn parse(i: &[u8]) -> IResult<&[u8], Self, nom::error::Error<&[u8]>> {
        let (i, real_count) = u32::parse_le(i)?;
        let (i, (_header, _size)) = alloc_field(i)?;
        let (i, raw) = take(real_count * 4)(i)?; // Each FormID is 4 bytes
        let (_, ids) = many0(FormId::parse_le)(raw)?;
        Ok((i, Self(ids)))
        
    }
}