Struct binary_rw::BinaryReader

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

Read from a stream.

Implementations§

source§

impl<'a> BinaryReader<'a>

source

pub fn new(stream: &'a mut impl ReadStream, endian: Endian) -> Self

Create a binary reader with the given endianness.

source

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

Read a length-prefixed String from the stream.

source

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

Read a 7bit encoded length-prefixed String from the stream.

source

pub fn swap_endianness(&mut self)

Swap endianness to allow for reversing the reading mid stream

source

pub fn read_char(&mut self) -> Result<char>

Read a character from the stream.

source

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

Read a bool from the stream.

source

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

Read a f32 from the stream.

source

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

Read a f64 from the stream.

source

pub fn read_isize(&mut self) -> Result<isize>

Read an isize from the stream.

source

pub fn read_usize(&mut self) -> Result<usize>

Read a usize from the stream.

source

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

Read a u64 from the stream.

source

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

Read an i64 from the stream.

source

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

Read a u32 from the stream.

source

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

Read an i32 from the stream.

source

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

Read a u16 from the stream.

source

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

Read an i16 from the stream.

source

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

Read a u8 from the stream.

source

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

Read an i8 from the stream.

source

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

Read 7bit encoded i32 from the stream

source

pub fn read_7bit_encoded_usize(&mut self) -> Result<usize>

Read 7bit encoded usize from the stream

source

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

Read 7bit encoded u32 from the stream

source

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

Read bytes from the stream into a buffer.

Trait Implementations§

source§

impl<'a> SeekStream for BinaryReader<'a>

source§

fn seek(&mut self, to: usize) -> Result<usize>

Seek to a position.
source§

fn tell(&mut self) -> Result<usize>

Get the current position.
source§

fn len(&self) -> Result<usize>

Get the length of the stream.

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>,

§

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>,

§

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.