pub struct FrameDecoder { /* private fields */ }Expand description
Streaming frame decoder that maintains an internal buffer.
Call push_bytes with data read from the socket, then call
try_decode to extract complete frames. Incomplete frames
are buffered until enough data arrives.
Implementations§
Source§impl FrameDecoder
impl FrameDecoder
Sourcepub fn push_bytes(&mut self, data: &[u8])
pub fn push_bytes(&mut self, data: &[u8])
Append raw bytes received from the transport.
Sourcepub fn try_decode(&mut self) -> Result<Option<(FrameHeader, Vec<u8>)>>
pub fn try_decode(&mut self) -> Result<Option<(FrameHeader, Vec<u8>)>>
Attempt to decode one complete frame from the buffer.
Returns Ok(Some((header, payload))) if a complete frame was decoded.
The decoded bytes are removed from the internal buffer.
Returns Ok(None) if more data is needed.
Returns Err if the frame is malformed.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Return the number of buffered bytes waiting to be decoded.
Trait Implementations§
Source§impl Debug for FrameDecoder
impl Debug for FrameDecoder
Source§impl Default for FrameDecoder
impl Default for FrameDecoder
Source§fn default() -> FrameDecoder
fn default() -> FrameDecoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FrameDecoder
impl RefUnwindSafe for FrameDecoder
impl Send for FrameDecoder
impl Sync for FrameDecoder
impl Unpin for FrameDecoder
impl UnsafeUnpin for FrameDecoder
impl UnwindSafe for FrameDecoder
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