pub trait Decoder {
type DecodeItem;
type DecodeError: Debug;
// Required method
fn decode(
&self,
src: &mut BytesMut,
) -> Result<Option<Self::DecodeItem>, Self::DecodeError>;
// Provided method
fn decode_vec(
&self,
src: &mut BytesVec,
) -> Result<Option<Self::DecodeItem>, Self::DecodeError> { ... }
}
Expand description
Decoding of frames via buffers.
Required Associated Types§
Sourcetype DecodeItem
type DecodeItem
The type of decoded frames.
Sourcetype DecodeError: Debug
type DecodeError: Debug
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§
Sourcefn decode(
&self,
src: &mut BytesMut,
) -> Result<Option<Self::DecodeItem>, Self::DecodeError>
fn decode( &self, src: &mut BytesMut, ) -> Result<Option<Self::DecodeItem>, Self::DecodeError>
Attempts to decode a frame from the provided buffer of bytes.
Provided Methods§
Sourcefn decode_vec(
&self,
src: &mut BytesVec,
) -> Result<Option<Self::DecodeItem>, Self::DecodeError>
fn decode_vec( &self, src: &mut BytesVec, ) -> Result<Option<Self::DecodeItem>, Self::DecodeError>
Attempts to decode a frame from the provided buffer of bytes.