Skip to main content

BinaryReader

Struct BinaryReader 

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

Low-level binary data reader with position tracking

Implementations§

Source§

impl BinaryReader

Source

pub fn new(data: Vec<u8>) -> Self

Create a new reader from raw bytes

Source

pub fn position(&self) -> usize

Current position in the buffer

Source

pub fn seek(&mut self, pos: usize) -> ParserResult<()>

Set position in the buffer

Source

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

Read a single byte

Source

pub fn peek_u8(&self) -> ParserResult<u8>

Peek at the next byte without advancing

Source

pub fn read_u16_le(&mut self) -> ParserResult<u16>

Read a 16-bit unsigned integer (little-endian)

Source

pub fn read_u32_le(&mut self) -> ParserResult<u32>

Read a 32-bit unsigned integer (little-endian)

Source

pub fn read_u64_le(&mut self) -> ParserResult<u64>

Read a 64-bit unsigned integer (little-endian)

Source

pub fn read_f32_le(&mut self) -> ParserResult<f32>

Read a 32-bit float (little-endian)

Source

pub fn read_f64_le(&mut self) -> ParserResult<f64>

Read a 64-bit float (little-endian)

Source

pub fn read_string(&mut self, len: usize) -> ParserResult<String>

Read a string of specific length

Source

pub fn read_cstring(&mut self) -> ParserResult<String>

Read a null-terminated string

Source

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

Read N bytes into a buffer

Source

pub fn is_eof(&self) -> bool

Check if at end of file

Source

pub fn len(&self) -> usize

Get total length

Source

pub fn is_empty(&self) -> bool

Check if buffer is empty

Source

pub fn remaining(&self) -> usize

Remaining bytes to read

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.