Reader

Struct Reader 

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

Reader for decoding values from a byte slice.

Implementations§

Source§

impl<'a> Reader<'a>

Source

pub fn new(data: &'a [u8], config: Config) -> Self

Create a new reader with the given byte slice and configuration.

Source

pub fn read_u8(&mut self) -> Result<u8>

Read a single byte.

Source

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

Read a u16 in little-endian format.

Source

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

Read a u32 in little-endian format.

Source

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

Read a u64 in little-endian format.

Source

pub fn read_i8(&mut self) -> Result<i8>

Read an i8.

Source

pub fn read_i16(&mut self) -> Result<i16>

Read an i16 in little-endian format.

Source

pub fn read_i32(&mut self) -> Result<i32>

Read an i32 in little-endian format.

Source

pub fn read_i64(&mut self) -> Result<i64>

Read an i64 in little-endian format.

Source

pub fn read_f32(&mut self) -> Result<f32>

Read an f32 in little-endian format.

Source

pub fn read_f64(&mut self) -> Result<f64>

Read an f64 in little-endian format.

Source

pub fn read_bool(&mut self) -> Result<bool>

Read a boolean (decoded from u8: 0 = false, 1 = true).

Source

pub fn read_bytes(&mut self, len: usize) -> Result<&'a [u8]>

Read a byte slice of the given length.

Source

pub fn config(&self) -> Config

Get the current configuration.

Source

pub fn bytes_read(&self) -> usize

Get the number of bytes read so far.

Source

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

Get the remaining bytes.

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> UnwindSafe for Reader<'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.