tarrasque

crates.io docs.rs travis-ci.com

A library for zero-allocation parsing of binary formats.

Released under the Apache License 2.0.

Example

```rust use tarrasque::{Endianness, Stream};

extract! { /// A 2D point. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub Point4 { /// The x-coordinate of this point. x: u16 = ([extract(endianness)]), /// The y-coordinate of this point. y: u16 = ([extract(endianness)]), } }

fn main() { let mut stream = Stream(&[1, 2, 3, 4, 5, 6, 7, 8]);

println!("{:?}", stream.extract::<Point, _>(Endianness::Big));
// Ok(Point { x: 258, y: 772 })

println!("{:?}", stream.extract::<Point, _>(Endianness::Little));
// Ok(Point { x: 1541, y: 2055 })

println!("{:?}", stream.extract::<Point, _>(Endianness::Big));
// Err(Insufficient(2))

} ```