simple_parse
A declarative converter for Rust type to and from binary.
It provides basic implementations for most standard Rust types and also provides a derive macro to automatically implement the trait on your own types !
For bit level control or more advanced features, take a look at deku.
Usage
use ;
let mut cursor: & = &;
// Decode bytes into a struct
let mut my_struct = from_reader?;
/// Modify the struct
my_struct.items.push;
/// Encode modified struct into bytes
let mut dst_buf: = Vec new;
my_struct.to_writer?;
//dst_buf == [1,3,0,0,0,0,0,0,0,0xDE,0xAD,0xBE,0xEF,0xBA,0xDC,0x0F,0xFE,0xFF,0xFF,0xFF,0xFF]
For complete examples see : examples
Features
Feature | Description |
---|---|
No-Copy parsing | simple_parse is able to generate references into byte slices (see struct.rs) |
count | Annotating a dynamically sized field with count allows it's number of items to live somewhere else in the struct. The default is to simply prepend the number of items as a u64 |
endian | Annotating structs/fields with endian gives control over how numbers will be parsed |
Custom read/write | Custom parsers can be writen for individual fields when simple_parse doesnt have the adequate default implementation |