Trait asynchronous_codec::Decoder

source ·
pub trait Decoder {
    type Item;
    type Error: From<Error>;

    // Required method
    fn decode(
        &mut self,
        src: &mut BytesMut,
    ) -> Result<Option<Self::Item>, Self::Error>;

    // Provided method
    fn decode_eof(
        &mut self,
        src: &mut BytesMut,
    ) -> Result<Option<Self::Item>, Self::Error> { ... }
}
Expand description

Decoding of frames via buffers, for use with FramedRead.

Required Associated Types§

source

type Item

The type of items returned by decode

source

type Error: From<Error>

The type of decoding errors.

Required Methods§

source

fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>

Decode an item from the src BytesMut into an item

Provided Methods§

source

fn decode_eof( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>

Called when the input stream reaches EOF, signaling a last attempt to decode

§Notes

The default implementation of this method invokes the Decoder::decode method.

Implementors§