pub struct Reader<'a> { /* private fields */ }Expand description
A zero-copy reader that advances through a byte slice.
Reader borrows the input buffer and tracks the current position,
returning sub-slices on reads so no allocation is needed.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub const fn new(buf: &'a [u8]) -> Self
pub const fn position(&self) -> usize
pub fn remaining(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn peek_u8(&self) -> Result<u8, DecodeError>
pub fn read_u8(&mut self) -> Result<u8, DecodeError>
pub fn read_exact(&mut self, len: usize) -> Result<&'a [u8], DecodeError>
pub fn read_be_u16(&mut self) -> Result<u16, DecodeError>
pub fn read_be_u32(&mut self) -> Result<u32, DecodeError>
Trait Implementations§
impl<'a> Copy for Reader<'a>
Auto Trait Implementations§
impl<'a> Freeze for Reader<'a>
impl<'a> RefUnwindSafe for Reader<'a>
impl<'a> Send for Reader<'a>
impl<'a> Sync for Reader<'a>
impl<'a> Unpin for Reader<'a>
impl<'a> UnsafeUnpin for Reader<'a>
impl<'a> UnwindSafe for Reader<'a>
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