pub struct FrameReader { /* private fields */ }Expand description
Reads length-prefixed frames from a byte buffer.
This struct maintains internal state for incremental parsing, allowing frames to be read from partial data as it arrives.
Implementations§
Source§impl FrameReader
impl FrameReader
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new frame reader with the specified initial capacity.
Sourcepub fn read_frame(&mut self) -> Result<Option<Vec<u8>>, ControlError>
pub fn read_frame(&mut self) -> Result<Option<Vec<u8>>, ControlError>
Attempts to read a complete frame from the buffer.
Returns Ok(Some(data)) if a complete frame is available,
Ok(None) if more data is needed, or an error if the frame
is invalid.
§Errors
Returns an error if the frame size exceeds MAX_FRAME_SIZE.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Returns the number of bytes currently buffered.
Trait Implementations§
Source§impl Debug for FrameReader
impl Debug for FrameReader
Source§impl Default for FrameReader
impl Default for FrameReader
Source§fn default() -> FrameReader
fn default() -> FrameReader
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FrameReader
impl RefUnwindSafe for FrameReader
impl Send for FrameReader
impl Sync for FrameReader
impl Unpin for FrameReader
impl UnwindSafe for FrameReader
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