Struct ReadBuf

Source
pub struct ReadBuf<'a> { /* private fields */ }
Expand description

A local memory slice to read from memory

Implementations§

Source§

impl<'a> ReadBuf<'a>

Source

pub fn from(slice: &'a [u8]) -> Self

Create a readbuf from a slice

Source

pub fn position(&self) -> usize

Source

pub fn expect_end(&mut self) -> Result<(), ReadError>

Check if everything has been properly consumed

Source

pub fn is_end(&self) -> bool

Check if we reach the end of the buffer

Source

pub fn skip_bytes(&mut self, sz: usize) -> Result<(), ReadError>

Skip a number of bytes from the buffer.

Source

pub fn get_slice(&mut self, sz: usize) -> Result<&'a [u8], ReadError>

Return a slice of the next bytes from the buffer

Source

pub fn get_slice_end(&mut self) -> &'a [u8]

Source

pub fn into_slice_mut(&mut self, slice: &mut [u8]) -> Result<(), ReadError>

Source

pub fn split_to(&mut self, sz: usize) -> Result<ReadBuf<'a>, ReadError>

Return a sub-buffer ending at the given byte offset

Source

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.

Source

pub fn get_u8(&mut self) -> Result<u8, ReadError>

Return the next u8 from the buffer

Source

pub fn get_u16(&mut self) -> Result<u16, ReadError>

Return the next u16 from the buffer

Source

pub fn get_u32(&mut self) -> Result<u32, ReadError>

Return the next u32 from the buffer

Source

pub fn get_nz_u32(&mut self) -> Result<NonZeroU32, ReadError>

Source

pub fn get_u64(&mut self) -> Result<u64, ReadError>

Return the next u64 from the buffer

Source

pub fn get_nz_u64(&mut self) -> Result<NonZeroU64, ReadError>

Source

pub fn get_u128(&mut self) -> Result<u128, ReadError>

Return the next u128 from the buffer

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V