Struct BinaryReader

Source
pub struct BinaryReader { /* private fields */ }
Expand description

Binary data reader

Implementations§

Source§

impl BinaryReader

Source

pub fn from_path(path: &str) -> Result<Self, Error>

Create a BinaryReader from a file path.

Source

pub fn from_file(file: File) -> Result<Self, Error>

Create a BinaryReader from a File.

Source

pub fn from_bytes(bytes: &[u8]) -> Self

Create a BinaryReader from a u8 slice.

Source

pub fn read(&mut self, len: u64) -> Result<Vec<u8>, Error>

Read a specified number of bytes.

Source

pub fn seek(&mut self, pos: u64) -> Result<(), Error>

Seek to a specified position in the data.

Source

pub fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seek a specified amount of bytes in the data.

Source

pub fn pos(&self) -> u64

Return the current position in the data.

Source

pub fn is_file(&self) -> bool

Returns true if the reader is reading from a real file and false if it is reading from a buffer in memory.

Source

pub fn size(&self) -> u64

Returns size of the data.

Source

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

Read a u8 from the data.

Source

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

Read a u16 from the data. (Little Endian)

Source

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

Read a u32 from the data. (Little Endian)

Source

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

Read a u64 from the data. (Little Endian)

Source

pub fn read_u128(&mut self) -> Result<u128, Error>

Read a u128 from the data. (Little Endian)

Source

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

Read a i16 from the data. (Little Endian)

Source

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

Read a i32 from the data. (Little Endian)

Source

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

Read a i64 from the data. (Little Endian)

Source

pub fn read_i128(&mut self) -> Result<i128, Error>

Read a i128 from the data. (Little Endian)

Source

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

Read a f32 from the data. (Little Endian)

Source

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

Read a f64 from the data. (Little Endian)

Source

pub fn read_u16_be(&mut self) -> Result<u16, Error>

Read a u16 from the data. (Big Endian)

Source

pub fn read_u32_be(&mut self) -> Result<u32, Error>

Read a u32 from the data. (Big Endian)

Source

pub fn read_u64_be(&mut self) -> Result<u64, Error>

Read a u64 from the data. (Big Endian)

Source

pub fn read_u128_be(&mut self) -> Result<u128, Error>

Read a u128 from the data. (Big Endian)

Source

pub fn read_i16_be(&mut self) -> Result<i16, Error>

Read a i16 from the data. (Big Endian)

Source

pub fn read_i32_be(&mut self) -> Result<i32, Error>

Read a i32 from the data. (Big Endian)

Source

pub fn read_i64_be(&mut self) -> Result<i64, Error>

Read a i64 from the data. (Big Endian)

Source

pub fn read_i128_be(&mut self) -> Result<i128, Error>

Read a i128 from the data. (Big Endian)

Source

pub fn read_f32_be(&mut self) -> Result<f32, Error>

Read a f32 from the data. (Big Endian)

Source

pub fn read_f64_be(&mut self) -> Result<f64, Error>

Read a f64 from the data. (Big Endian)

Source

pub fn read_string_ascii_limited(&mut self, len: u64) -> Result<String, Error>

Read a string of a specified length from the data. Fails if it encounters a non-ascii character.

Source

pub fn read_string_ascii(&mut self) -> String

Read a string from the data until it encounters a NUL(0x00)/non-ascii character or the end of the file. Doesn’t fail.

Trait Implementations§

Source§

impl Debug for BinaryReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.