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.
Sourcepub fn drain_bytes(&mut self) -> Vec<u8> ⓘ
pub fn drain_bytes(&mut self) -> Vec<u8> ⓘ
Drain all buffered bytes from the decoder.
This is used when switching from frame-decoded mode to raw chunk-streaming mode (e.g., archive upload). Any bytes already read from the transport but not yet consumed as a frame are returned so they can be processed as chunk data.