pub struct Parser { /* private fields */ }Expand description
A streaming parser for RESP3 frames.
This parser allows feeding data in chunks and extracting frames as they become available. It maintains an internal buffer of accumulated data and attempts to parse frames from it.
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn feed(&mut self, data: Bytes)
pub fn feed(&mut self, data: Bytes)
Feeds a chunk of data into the parser.
The data is appended to the internal buffer.
Sourcepub fn next_frame(&mut self) -> Result<Option<Frame>, ParseError>
pub fn next_frame(&mut self) -> Result<Option<Frame>, ParseError>
Attempts to extract the next complete frame from the buffer.
Returns Ok(None) if there is not enough data to parse a complete frame.
Returns Ok(Some(frame)) on success, consuming the parsed bytes.
Returns Err on protocol errors, clearing the buffer.
Sourcepub fn buffered_bytes(&self) -> usize
pub fn buffered_bytes(&self) -> usize
Returns the number of bytes currently in the buffer.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnsafeUnpin for Parser
impl UnwindSafe for Parser
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