pub struct ReadBuf<'a> { /* private fields */ }
Expand description
A local memory slice to read from memory
Implementations§
Source§impl<'a> ReadBuf<'a>
impl<'a> ReadBuf<'a>
pub fn position(&self) -> usize
Sourcepub fn expect_end(&mut self) -> Result<(), ReadError>
pub fn expect_end(&mut self) -> Result<(), ReadError>
Check if everything has been properly consumed
Sourcepub fn skip_bytes(&mut self, sz: usize) -> Result<(), ReadError>
pub fn skip_bytes(&mut self, sz: usize) -> Result<(), ReadError>
Skip a number of bytes from the buffer.
Sourcepub fn get_slice(&mut self, sz: usize) -> Result<&'a [u8], ReadError>
pub fn get_slice(&mut self, sz: usize) -> Result<&'a [u8], ReadError>
Return a slice of the next bytes from the buffer
pub fn get_slice_end(&mut self) -> &'a [u8] ⓘ
pub fn into_slice_mut(&mut self, slice: &mut [u8]) -> Result<(), ReadError>
Sourcepub fn split_to(&mut self, sz: usize) -> Result<ReadBuf<'a>, ReadError>
pub fn split_to(&mut self, sz: usize) -> Result<ReadBuf<'a>, ReadError>
Return a sub-buffer ending at the given byte offset
Sourcepub fn peek_u8(&mut self) -> Result<u8, ReadError>
pub fn peek_u8(&mut self) -> Result<u8, ReadError>
Peek at the next u8 from the buffer. the cursor is not advanced to the next byte.
pub fn get_nz_u32(&mut self) -> Result<NonZeroU32, ReadError>
pub fn get_nz_u64(&mut self) -> Result<NonZeroU64, ReadError>
pub fn debug(&self) -> String
Auto Trait Implementations§
impl<'a> Freeze for ReadBuf<'a>
impl<'a> RefUnwindSafe for ReadBuf<'a>
impl<'a> Send for ReadBuf<'a>
impl<'a> Sync for ReadBuf<'a>
impl<'a> Unpin for ReadBuf<'a>
impl<'a> UnwindSafe for ReadBuf<'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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more