Skip to main content

BinaryReader

Struct BinaryReader 

Source
pub struct BinaryReader<R: Read, F: BinaryFormat> { /* private fields */ }
Expand description

Generic binary reader with position tracking.

Implementations§

Source§

impl<R: Read, F: BinaryFormat> BinaryReader<R, F>

Source

pub fn new(inner: R) -> Self

Create a new binary reader.

Source

pub fn position(&self) -> u64

Get current position.

Source

pub fn get_position(&self) -> u64

Get current position (alias for position).

Source

pub fn set_position(&mut self, pos: u64) -> Result<u64>
where R: Seek,

Set current position (alias for seek).

Source

pub fn stream_position(&mut self) -> Result<u64>
where R: Seek,

Get stream position.

Source

pub fn add_error(&mut self, error: GaiaError)

Add a diagnostic error.

Source

pub fn take_errors(&mut self) -> Vec<GaiaError>

Take all collected diagnostic errors.

Source

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

Read a u8 value.

Source

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

Read a u16 value.

Source

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

Read a u32 value.

Source

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

Read a u64 value.

Source

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

Read an i16 value.

Source

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

Read an i32 value.

Source

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

Read an i64 value.

Source

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

Read an f32 value.

Source

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

Read an f64 value.

Source

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

Read raw bytes.

Source

pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Read into a buffer.

Source

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

Read to end of source.

Source§

impl<R: Read + Seek, F: BinaryFormat> BinaryReader<R, F>

Source

pub fn seek_gaia(&mut self, pos: SeekFrom) -> Result<u64>

Seek to a position.

Trait Implementations§

Source§

impl<R: Read + Debug, F: BinaryFormat> Debug for BinaryReader<R, F>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<R: Read + Seek, F: BinaryFormat> Seek for BinaryReader<R, F>

Source§

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

Seek to an offset, in bytes, in a stream. Read more
1.55.0 · Source§

fn rewind(&mut self) -> Result<(), Error>

Rewind to the beginning of a stream. Read more
Source§

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

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.51.0 · Source§

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

Returns the current seek position from the start of the stream. Read more
1.80.0 · Source§

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

Seeks relative to the current position. Read more

Auto Trait Implementations§

§

impl<R, F> Freeze for BinaryReader<R, F>
where R: Freeze,

§

impl<R, F> !RefUnwindSafe for BinaryReader<R, F>

§

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

§

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

§

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

§

impl<R, F> UnsafeUnpin for BinaryReader<R, F>
where R: UnsafeUnpin,

§

impl<R, F> !UnwindSafe for BinaryReader<R, F>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more