pub trait Decoder<'de>: Sized {
    fn decoder(_: &mut &'de [u8]) -> Result<Self, Box<dyn Error + Send + Sync>>;

    fn decode(data: &'de [u8]) -> Result<Self, Box<dyn Error + Send + Sync>> { ... }
}
Expand description

This trait used to deserialize the data structure from binary format.

Required Methods

Deserialize the data from binary format.

Provided Methods

Example
use bin_layout::Decoder;

#[derive(Decoder, PartialEq, Debug)]
struct FooBar {
    foo: u8,
    bar: [u8; 2],
}

let foobar = FooBar::decode(&[1, 2, 3]).unwrap();
assert_eq!(foobar, FooBar { foo: 1, bar: [2, 3] });

Implementations on Foreign Types

Implementors