Skip to main content

BufferReader

Struct BufferReader 

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

Simple buffer reader for reading bytes from a slice

Implementations§

Source§

impl<'a> BufferReader<'a>

Source

pub fn new(buffer: &'a [u8]) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn read_byte(&mut self) -> Result<u8, ReadTracingError>

Reads a single byte from the buffer. Returns None if end of buffer is reached.

Source

pub fn read_bytes(&mut self, length: usize) -> Result<&[u8], ReadTracingError>

Reads a slice of bytes of the given length from the buffer. Returns None if not enough data is available.

Source

pub fn read_varint(&mut self) -> Result<u64, ReadTracingError>

Reads a LEB128 (VarInt) encoded u64.

Source

pub fn read_u16(&mut self) -> Result<u16, ReadTracingError>

Reads a little-endian u16 from the buffer

Source

pub fn read_u32(&mut self) -> Result<u32, ReadTracingError>

Reads a little-endian u32 from the buffer

Source

pub fn read_u64(&mut self) -> Result<u64, ReadTracingError>

Reads a little-endian u64 from the buffer

Source

pub fn get_position(&self) -> usize

Auto Trait Implementations§

§

impl<'a> Freeze for BufferReader<'a>

§

impl<'a> RefUnwindSafe for BufferReader<'a>

§

impl<'a> Send for BufferReader<'a>

§

impl<'a> Sync for BufferReader<'a>

§

impl<'a> Unpin for BufferReader<'a>

§

impl<'a> UnwindSafe for BufferReader<'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, 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.