rust-bakery / nom

Rust parser combinator framework
MIT License
9.38k stars 805 forks source link

What is the right way to parse chunk based file formats? #1689

Open auronen opened 1 year ago

auronen commented 1 year ago

Hello, what is the idiomatic way to parse chunk based binary formats (example)? Is there a nice built-in way to pass in an extra self parameter, to accumulate the chunk contents into a struct instance?

For a chunk based file format that has only one level of chunk structure one could potentially parse the chunks as enum separately and then move the data to the instance of the struct. But the linked format has nested chunks and I have no idea how to approach this.