pub struct Scanner { /* private fields */ }Expand description
A stateless framing scanner: each scan call attempts
to delimit one checksum-verified frame from the start of a buffer.
The Default scanner caps frames at 1 MiB; use Scanner::new to
choose a different cap.
Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn new(max_frame_size: usize) -> Self
pub fn new(max_frame_size: usize) -> Self
Creates a scanner that reports frames longer than max_frame_size
bytes as GarbledReason::FrameTooLarge.
Sourcepub fn scan<'a>(&self, buf: &'a [u8]) -> Outcome<'a>
pub fn scan<'a>(&self, buf: &'a [u8]) -> Outcome<'a>
Scans one frame from the start of buf.
buf must begin at a presumed message boundary: the start of the
stream, or the position reached by advancing past a previous outcome.
After Outcome::Frame, advance by frame.bytes.len(); after
Outcome::Garbled, advance by skipped; on
Outcome::Incomplete, read more bytes and scan again from the
same position.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnsafeUnpin for Scanner
impl UnwindSafe for Scanner
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