pub struct Decoder<const SENTINEL: u8 = DEFAULT_SENTINEL, const MAX_LEN: usize = DEFAULT_MAX_LEN> { /* private fields */ }Expand description
Frame decoder.
This type implements Decoder;
it decodes into BytesMut.
This type can be customized via generic parameters:
SENTINEL: Choose a byte to be used as a frame separator.
The corresponding Encoder must use the same value.
Refer to the crate documentation for more details on choosing a sentinel.
MAX_LEN: Choose the maximum size of a message,
or set to 0 for unlimited message sizes.
This parameter is used as a safety measure to prevent
running out of memory. If any message exceeds this limit,
decoding will return DecodeError::FrameOverflow.
Implementations§
Trait Implementations§
Source§impl<const SENTINEL: u8, const MAX_LEN: usize> Decoder for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> Decoder for Decoder<SENTINEL, MAX_LEN>
Source§type Error = DecodeError
type Error = DecodeError
The type of unrecoverable frame decoding errors. Read more
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<BytesMut>, Self::Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<BytesMut>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
Auto Trait Implementations§
impl<const SENTINEL: u8, const MAX_LEN: usize> Freeze for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> RefUnwindSafe for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> Send for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> Sync for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> Unpin for Decoder<SENTINEL, MAX_LEN>
impl<const SENTINEL: u8, const MAX_LEN: usize> UnwindSafe for Decoder<SENTINEL, MAX_LEN>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more