binrw
binrw helps you write maintainable & easy-to-read declarative binary data parsers using ✨macro magic✨.
Features
- Generates efficient data parsers for structs and enums using
#[derive]
- Reads data from any source using standard
io::Read + io::Seek
streams - Directives in attributes handle common binary parsing tasks like matching magic numbers, byte ordering, padding & alignment, data validation, and more
- Includes reusable types for common data structures like null-terminated strings and data indirection using offsets
- Parses types from third-party crates using free functions or value maps
- Uses efficient in-memory representations (does not require
#[repr(C)]
or#[repr(packed)]
) - Code in attributes is written as code, not as strings
- Supports no_std
Usage
let mut reader = new;
let dog: Dog = reader.read_ne.unwrap;
assert_eq!;
assert_eq!
For more information, including a more detailed overview of binrw, visit the documentation.