pub struct BinaryReader { /* private fields */ }
Expand description
Binary data reader
Implementations§
Source§impl BinaryReader
impl BinaryReader
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Create a BinaryReader
from a u8
slice.
Sourcepub fn seek(&mut self, pos: u64) -> Result<(), Error>
pub fn seek(&mut self, pos: u64) -> Result<(), Error>
Seek to a specified position in the data.
Sourcepub fn seek_relative(&mut self, offset: i64) -> Result<(), Error>
pub fn seek_relative(&mut self, offset: i64) -> Result<(), Error>
Seek a specified amount of bytes in the data.
Sourcepub fn is_file(&self) -> bool
pub fn is_file(&self) -> bool
Returns true
if the reader is reading from a real file and false
if it is reading from a buffer in memory.
Sourcepub fn read_u16_be(&mut self) -> Result<u16, Error>
pub fn read_u16_be(&mut self) -> Result<u16, Error>
Read a u16
from the data. (Big Endian)
Sourcepub fn read_u32_be(&mut self) -> Result<u32, Error>
pub fn read_u32_be(&mut self) -> Result<u32, Error>
Read a u32
from the data. (Big Endian)
Sourcepub fn read_u64_be(&mut self) -> Result<u64, Error>
pub fn read_u64_be(&mut self) -> Result<u64, Error>
Read a u64
from the data. (Big Endian)
Sourcepub fn read_u128_be(&mut self) -> Result<u128, Error>
pub fn read_u128_be(&mut self) -> Result<u128, Error>
Read a u128
from the data. (Big Endian)
Sourcepub fn read_i16_be(&mut self) -> Result<i16, Error>
pub fn read_i16_be(&mut self) -> Result<i16, Error>
Read a i16
from the data. (Big Endian)
Sourcepub fn read_i32_be(&mut self) -> Result<i32, Error>
pub fn read_i32_be(&mut self) -> Result<i32, Error>
Read a i32
from the data. (Big Endian)
Sourcepub fn read_i64_be(&mut self) -> Result<i64, Error>
pub fn read_i64_be(&mut self) -> Result<i64, Error>
Read a i64
from the data. (Big Endian)
Sourcepub fn read_i128_be(&mut self) -> Result<i128, Error>
pub fn read_i128_be(&mut self) -> Result<i128, Error>
Read a i128
from the data. (Big Endian)
Sourcepub fn read_f32_be(&mut self) -> Result<f32, Error>
pub fn read_f32_be(&mut self) -> Result<f32, Error>
Read a f32
from the data. (Big Endian)
Sourcepub fn read_f64_be(&mut self) -> Result<f64, Error>
pub fn read_f64_be(&mut self) -> Result<f64, Error>
Read a f64
from the data. (Big Endian)
Sourcepub fn read_string_ascii_limited(&mut self, len: u64) -> Result<String, Error>
pub fn read_string_ascii_limited(&mut self, len: u64) -> Result<String, Error>
Read a string of a specified length from the data. Fails if it encounters a non-ascii character.
Sourcepub fn read_string_ascii(&mut self) -> String
pub fn read_string_ascii(&mut self) -> String
Read a string from the data until it encounters a NUL(0x00)/non-ascii character or the end of the file. Doesn’t fail.