pub struct Decoder { /* private fields */ }Expand description
Stateful streaming decoder. Feed it bytes as they arrive, call
Decoder::try_next to pop off framed messages.
Implementations§
Source§impl Decoder
impl Decoder
pub fn new(opts: DecodeOptions) -> Self
Sourcepub fn feed(&mut self, bytes: &[u8])
pub fn feed(&mut self, bytes: &[u8])
Append bytes to the internal buffer. The decoder does not copy
again during [try_next]; ownership moves in.
Sourcepub fn try_next(&mut self) -> Result<Option<Message>, WireError>
pub fn try_next(&mut self) -> Result<Option<Message>, WireError>
Pop the next complete message off the buffer. Returns:
Ok(Some(msg))if one full frame was parsedOk(None)if we need more bytesErr(...)on a protocol violation (malformed / bad xxh3 / …)
Sourcepub fn buffered_bytes(&self) -> usize
pub fn buffered_bytes(&self) -> usize
Number of bytes buffered but not yet parsed into a message.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Decoder
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnsafeUnpin for Decoder
impl UnwindSafe for Decoder
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