BinaryReader

Struct BinaryReader 

Source
pub struct BinaryReader<'a> {
    pub stream: MemoryStream<'a>,
    pub endian: Endian,
}

Fields§

§stream: MemoryStream<'a>§endian: Endian

Implementations§

Source§

impl<'a> BinaryReader<'a>

Source

pub fn new_stream<'b>(stream: MemoryStream<'a>, endian: Endian) -> Self

Createa a new BinaryWriter with a predefined MemoryStream

Source

pub fn new_vec(buffer: &'a mut Vec<u8>, endian: Endian) -> Self

Createa a new BinaryWriter with a predefined Vec<u8> buffer

use binary_modifier::{BinaryReader, Endian};

let mut test_vec = vec![0,1,2,3,4,6,7,8,9,0];
let reader = BinaryReader::new(&mut test_vec, Endian::Little);
Source

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

Read a 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_bytes(&mut self, length: usize) -> Result<Vec<u8>>

Read bytes from the stream into a buffer.

Source

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

same as read_bytes but at a certain offset

Source

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

Reads a string by reading the length before

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.