packet_encoding

Trait Encodable

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§