pub struct BinaryReader<R>
where R: Read + Seek,
{ /* private fields */ }
Expand description

Read from a stream.

Implementations§

source§

impl<R: Read + Seek> BinaryReader<R>

source

pub fn new(stream: R, options: Options) -> Self

Create a binary reader with the given options.

source

pub fn seek(&mut self, to: SeekFrom) -> Result<u64>

Seek to a position.

source

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

Get the current seek position.

source

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

Get the length of this stream by seeking to the end and then restoring the previous cursor position.

source

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

Read a length-prefixed String from the 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>

Available on 32-bit only.

Read an isize from the stream.

source

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

Available on 32-bit only.

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_u128(&mut self) -> Result<u128>

Read a u128 from the stream.

source

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

Read an i128 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.

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for BinaryReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for BinaryReader<R>
where R: Send,

§

impl<R> Sync for BinaryReader<R>
where R: Sync,

§

impl<R> Unpin for BinaryReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for BinaryReader<R>
where R: UnwindSafe,

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.