Trait Decode

Source
pub trait Decode<'a>: Sized {
    type Output: Debug;
    type Error: From<Error> + Debug;

    // Required method
    fn decode(buff: &'a [u8]) -> Result<(Self::Output, usize), Self::Error>;
}
Expand description

Decode trait implemented for binary decodable objects

Required Associated Types§

Source

type Output: Debug

Output type (allows attaching lifetime bounds where required)

Source

type Error: From<Error> + Debug

Error type returned on parse error

Required Methods§

Source

fn decode(buff: &'a [u8]) -> Result<(Self::Output, usize), Self::Error>

Decode consumes a slice and returns an object and decoded 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§

Source§

impl<'a, T: DecodeOwned> Decode<'a> for T

Blanket Decode impl for DecodeOwned types