Open ebassi opened 4 years ago
You may find the scroll crate useful. It lets you parse a byte buffer with primitives like "read me a big-endian u32 at a given offset", and will return an error if the offset is past the bounds of the byte buffer.
Also just found the bytemuck crate to cast between &[u8]
and "plain old data" structs. This may allow easy casting to a struct that represents the whole header of a section, and later endian-flipping the fields as appropriate.
There's also https://github.com/rust-lang/rfcs/pull/2981, which would allow directly casting byte blobs, safely, to structs at some point in the future.
And of course nom if you want to go the normal parsing approach, which can also work zero-copy/zero-heap-allocation.
The shared-mime-info database has two representations:
aliases
,globs2
,icons
,magic
, etc.mime.cache
file, which contains all of the above in a single blob, easily memory mappableWe should add a parser for the
mime.cache
file, and use it whenever it's available, instead of loading all the other files.