Trait Decoder

Source
pub trait Decoder<const N: usize> {
    type Item;
    type Error: From<DecodeError>;

    // Required method
    fn from_bytes(
        &mut self,
        src: &mut Vec<u8, N>,
    ) -> Result<Option<Self::Item>, Self::Error>;
}
Expand description

Decoder trait to decode inbound messages from a source and produce human-readable and programmable output. Similar but adapted from the tokio_utils Decoder to be used within a no_std environment.

Required Associated Types§

Source

type Item

The type of decoded frames

Source

type Error: From<DecodeError>

The type of unrecoverable frame decoding errors.

If an individual message is ill-formed but can be ignored without interfering with the processing of future messages, it may be more useful to report the failure as an Item.

Required Methods§

Source

fn from_bytes( &mut self, src: &mut Vec<u8, N>, ) -> Result<Option<Self::Item>, Self::Error>

Attempts to decode a frame from the provided buffer of bytes.

Implementors§