pub struct BinaryReader<'a> { /* private fields */ }Expand description
Binary reader for Unity file formats
Implementations§
Source§impl<'a> BinaryReader<'a>
impl<'a> BinaryReader<'a>
Sourcepub fn new(data: &'a [u8], byte_order: ByteOrder) -> Self
pub fn new(data: &'a [u8], byte_order: ByteOrder) -> Self
Create a new binary reader from byte slice
Sourcepub fn set_position(&mut self, pos: u64) -> Result<()>
pub fn set_position(&mut self, pos: u64) -> Result<()>
Set position in the stream
Sourcepub fn seek(&mut self, offset: i64) -> Result<u64>
pub fn seek(&mut self, offset: i64) -> Result<u64>
Seek to a position relative to the current position
Sourcepub fn read_remaining(&mut self) -> &[u8] ⓘ
pub fn read_remaining(&mut self) -> &[u8] ⓘ
Read all remaining bytes
Sourcepub fn read_cstring(&mut self) -> Result<String>
pub fn read_cstring(&mut self) -> Result<String>
Read a null-terminated string
Sourcepub fn read_string(&mut self) -> Result<String>
pub fn read_string(&mut self) -> Result<String>
Read a string with a length prefix (32-bit)
Sourcepub fn read_string_fixed(&mut self, length: usize) -> Result<String>
pub fn read_string_fixed(&mut self, length: usize) -> Result<String>
Read a string with a specific length
Sourcepub fn read_aligned_string(&mut self) -> Result<String>
pub fn read_aligned_string(&mut self) -> Result<String>
Read an aligned string (Unity format)
Sourcepub fn byte_order(&self) -> ByteOrder
pub fn byte_order(&self) -> ByteOrder
Get the current byte order
Sourcepub fn set_byte_order(&mut self, byte_order: ByteOrder)
pub fn set_byte_order(&mut self, byte_order: ByteOrder)
Set the byte order
Sourcepub fn remaining_slice(&self) -> &[u8] ⓘ
pub fn remaining_slice(&self) -> &[u8] ⓘ
Get a slice of the remaining data
Sourcepub fn sub_reader(
&self,
offset: usize,
length: usize,
) -> Result<BinaryReader<'a>>
pub fn sub_reader( &self, offset: usize, length: usize, ) -> Result<BinaryReader<'a>>
Create a new reader for a subset of the data
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more