pub trait Encoder {
    fn encoder(&self, _: &mut impl Write) -> Result<()>;

    fn encode(&self) -> Vec<u8> { ... }
}
Expand description

This trait used to serialize the data structure into binary format.

Required Methods

Serialize the data into binary format.

Provided Methods

Example
use bin_layout::Encoder;

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

Implementations on Foreign Types

Implementors