pub trait Decoder<'de, E>: Sized {
    fn decoder(_: &mut Cursor<&'de [u8]>) -> Result<Self, E>;

    fn decode(data: &'de [u8]) -> Result<Self, E> { ... }
}

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: Result<FooBar, ()> = FooBar::decode(&[1, 2, 3]);
assert_eq!(foobar, Ok(FooBar { foo: 1, bar: [2, 3] }));

Implementations on Foreign Types

Implementors