pub trait Encoder: Sized {
    const SIZE: usize;

    fn encoder(self, _: &mut Cursor<impl Bytes>);

    fn size_hint(&self) -> usize { ... }
    fn encode(self) -> Vec<u8> { ... }
}

Associated Constants

The size of the data type in bytes. (padding not included)

Required methods

Serialize the data to binary format.

Provided methods

Calculate total estimated size of the data structure in bytes.

Example
use bin_layout::Encoder;

#[derive(Encoder)]
struct FooBar {
    foo: u8,
    bar: [u8; 2],
}
let foobar = FooBar { foo: 1, bar: [2, 3] }.encode();
assert_eq!(vec![1, 2, 3], foobar);

Implementations on Foreign Types

Implementors