pub struct BinaryReader {
pub data: Vec<u8>,
pub pos: usize,
pub length: usize,
pub endian: Endian,
}
Expand description
Binary reader.
Fields§
§data: Vec<u8>
The buffer data.
pos: usize
The current position.
length: usize
The length of the buffer.
endian: Endian
The endian of the buffer.
Implementations§
Source§impl BinaryReader
impl BinaryReader
Sourcepub fn from_u8(get: &[u8]) -> BinaryReader
pub fn from_u8(get: &[u8]) -> BinaryReader
Initialize BinaryReader from u8
slice.
Sourcepub fn from_file(file: &mut File) -> BinaryReader
pub fn from_file(file: &mut File) -> BinaryReader
Initialize BinaryReader from std::fs::File
.
Sourcepub fn set_endian(&mut self, endian: Endian)
pub fn set_endian(&mut self, endian: Endian)
Set endian for read method.
pub fn adv(&mut self, size: usize)
pub fn align(&mut self, size: usize)
Sourcepub fn read_bytes(&mut self, bytes: usize) -> Result<&[u8]>
pub fn read_bytes(&mut self, bytes: usize) -> Result<&[u8]>
Read provided length size bytes.
Similar to BinaryReader::read
but this returns std::io::Result
instead of Option
.
Sourcepub fn read_cstr(&mut self) -> Result<String>
pub fn read_cstr(&mut self) -> Result<String>
Read cstr strings until null
(aka 0x00
) using std::string::String::from_utf8
.
Sourcepub fn read_cstr_lossy(&mut self) -> Result<String>
pub fn read_cstr_lossy(&mut self) -> Result<String>
Read cstr strings until null
(aka 0x00
) using std::string::String::from_utf8_lossy
.
Trait Implementations§
Source§impl Clone for BinaryReader
impl Clone for BinaryReader
Source§fn clone(&self) -> BinaryReader
fn clone(&self) -> BinaryReader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for BinaryReader
impl RefUnwindSafe for BinaryReader
impl Send for BinaryReader
impl Sync for BinaryReader
impl Unpin for BinaryReader
impl UnwindSafe for BinaryReader
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