pub trait Encodable: Sized {
    type Error;

    // Required methods
    fn encoded_len(&self) -> usize;
    fn encode(&self, buf: &mut [u8]) -> Result<(), Self::Error>;
}
Expand description

An encodable type can write itself into a byte buffer.

Required Associated Types§

Required Methods§

source

fn encoded_len(&self) -> usize

Returns the number of bytes necessary to encode |self|.

source

fn encode(&self, buf: &mut [u8]) -> Result<(), Self::Error>

Writes the encoded version of |self| at the start of |buf|. |buf| must be at least |self.encoded_len()| length.

Object Safety§

This trait is not object safe.

Implementors§