BinaryReader

Struct BinaryReader 

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

BinaryReader is used to deserialize various data types from a byte buffer.

Implementations§

Source§

impl<'a> BinaryReader<'a>

Source

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

Creates a new BinaryReader with the given byte slice.

Source

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

Reads a u8 value from the buffer.

Source

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

Reads a u16 value from the buffer in little-endian order.

Source

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

Reads a u32 value from the buffer in little-endian order.

Source

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

Reads a u64 value from the buffer in little-endian order.

Source

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

Reads an i8 value from the buffer.

Source

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

Reads an i16 value from the buffer in little-endian order.

Source

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

Reads an i32 value from the buffer in little-endian order.

Source

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

Reads an i64 value from the buffer in little-endian order.

Source

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

Reads a f32 value from the buffer in little-endian order.

Source

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

Reads a f64 value from the buffer in little-endian order.

Source

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

Reads a bool value from the buffer (expects 0 or 1).

Source

pub fn read_string(&mut self) -> Result<String, String>

Reads a string from the buffer. Expects a u32 length followed by UTF-8 bytes.

Source

pub fn read_vec_u8(&mut self) -> Result<Vec<u8>, String>

Reads a vector of u8 from the buffer. Expects a u32 length followed by bytes.

Source

pub fn read_vec_u16(&mut self) -> Result<Vec<u16>, String>

Reads a vector of u16 from the buffer. Expects a u32 length followed by u16 values.

Source

pub fn read_vec_u32(&mut self) -> Result<Vec<u32>, String>

Reads a vector of u32 from the buffer. Expects a u32 length followed by u32 values.

Source

pub fn read_vec_u64(&mut self) -> Result<Vec<u64>, String>

Reads a vector of u64 from the buffer. Expects a u32 length followed by u64 values.

Source

pub fn read_vec_i8(&mut self) -> Result<Vec<i8>, String>

Reads a vector of i8 from the buffer. Expects a u32 length followed by i8 values.

Source

pub fn read_vec_i16(&mut self) -> Result<Vec<i16>, String>

Reads a vector of i16 from the buffer. Expects a u32 length followed by i16 values.

Source

pub fn read_vec_i32(&mut self) -> Result<Vec<i32>, String>

Reads a vector of i32 from the buffer. Expects a u32 length followed by i32 values.

Source

pub fn read_vec_i64(&mut self) -> Result<Vec<i64>, String>

Reads a vector of i64 from the buffer. Expects a u32 length followed by i64 values.

Source

pub fn read_vec_f32(&mut self) -> Result<Vec<f32>, String>

Reads a vector of f32 from the buffer. Expects a u32 length followed by f32 values.

Source

pub fn read_vec_f64(&mut self) -> Result<Vec<f64>, String>

Reads a vector of f64 from the buffer. Expects a u32 length followed by f64 values.

Source

pub fn read_vec_string(&mut self) -> Result<Vec<String>, String>

Reads a vector of strings from the buffer. Expects a u32 length followed by serialized strings.

Auto Trait Implementations§

§

impl<'a> Freeze for BinaryReader<'a>

§

impl<'a> RefUnwindSafe for BinaryReader<'a>

§

impl<'a> Send for BinaryReader<'a>

§

impl<'a> Sync for BinaryReader<'a>

§

impl<'a> Unpin for BinaryReader<'a>

§

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