pub struct FrameDecoder { /* private fields */ }Expand description
Splits a byte stream into newline-delimited frames with a hard cap.
Implementations§
Source§impl FrameDecoder
impl FrameDecoder
Sourcepub fn new(max_frame_bytes: usize) -> Self
pub fn new(max_frame_bytes: usize) -> Self
A decoder whose frames never exceed max_frame_bytes.
Sourcepub fn append(&mut self, chunk: &[u8]) -> Result<Vec<Vec<u8>>, FrameError>
pub fn append(&mut self, chunk: &[u8]) -> Result<Vec<Vec<u8>>, FrameError>
Feeds one received chunk, returning every frame completed by it.
The cap is enforced across all chunks belonging to one frame: a peer
cannot bypass it by sending a large frame in small pieces. On breach
the decoder returns FrameError::ExceededLimit and the caller must
destroy the connection (both directions, both languages).
Sourcepub fn pending_bytes(&self) -> usize
pub fn pending_bytes(&self) -> usize
Bytes of the frame currently being assembled.
Trait Implementations§
Source§impl Debug for FrameDecoder
impl Debug for FrameDecoder
Auto Trait Implementations§
impl Forget for FrameDecoder
impl Freeze for FrameDecoder
impl Move for FrameDecoder
impl RefUnwindSafe for FrameDecoder
impl Send for FrameDecoderwhere
RawVecInner: Send,
impl Sync for FrameDecoderwhere
RawVecInner: Sync,
impl Unpin for FrameDecoder
impl UnsafeUnpin for FrameDecoder
impl UnwindSafe for FrameDecoderwhere
RawVecInner: UnwindSafe,
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