ogre 0.1.7

A rusty, dual-wielding Quake and Half-Life texture WAD parser.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use nom::{multi::count, IResult};

use crate::parser::repr::Directory;
use crate::parser::parse_entry;

/// Given an entry count, returns a function that parses a [`Directory`] from a byte slice.
pub fn parse_directory(entry_count: usize) -> impl Fn(&[u8]) -> IResult<&[u8], Directory> {
    move |i: &[u8]| {
        let (i, entries) = count(parse_entry, entry_count)(i)?;
        Ok((i, Directory(entries)))
    }
}