pub struct BinaryReader<'a> {
pub stream: MemoryStream<'a>,
pub endian: Endian,
}Fields§
§stream: MemoryStream<'a>§endian: EndianImplementations§
Source§impl<'a> BinaryReader<'a>
impl<'a> BinaryReader<'a>
Sourcepub fn new_stream<'b>(stream: MemoryStream<'a>, endian: Endian) -> Self
pub fn new_stream<'b>(stream: MemoryStream<'a>, endian: Endian) -> Self
Createa a new BinaryWriter with a predefined MemoryStream
Sourcepub fn new_vec(buffer: &'a mut Vec<u8>, endian: Endian) -> Self
pub fn new_vec(buffer: &'a mut Vec<u8>, endian: Endian) -> Self
Createa a new BinaryWriter with a predefined Vec<u8> buffer
use binary_modifier::{BinaryReader, Endian};
let mut test_vec = vec![0,1,2,3,4,6,7,8,9,0];
let reader = BinaryReader::new(&mut test_vec, Endian::Little);Sourcepub fn read_string(&mut self) -> Result<String>
pub fn read_string(&mut self) -> Result<String>
Read a length-prefixed String from the stream.
Sourcepub fn swap_endianness(&mut self)
pub fn swap_endianness(&mut self)
Swap endianness to allow for reversing the reading mid stream
Sourcepub fn read_isize(&mut self) -> Result<isize>
pub fn read_isize(&mut self) -> Result<isize>
Read an isize from the stream.
Sourcepub fn read_usize(&mut self) -> Result<usize>
pub fn read_usize(&mut self) -> Result<usize>
Read a usize from the stream.
Sourcepub fn read_bytes(&mut self, length: usize) -> Result<Vec<u8>>
pub fn read_bytes(&mut self, length: usize) -> Result<Vec<u8>>
Read bytes from the stream into a buffer.
Sourcepub fn read_bytes_at(
&mut self,
length: usize,
position: usize,
) -> Result<Vec<u8>>
pub fn read_bytes_at( &mut self, length: usize, position: usize, ) -> Result<Vec<u8>>
same as read_bytes but at a certain offset
Sourcepub fn read_big_string(&mut self) -> Result<String>
pub fn read_big_string(&mut self) -> Result<String>
Reads a string by reading the length before
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