pub trait BinaryReader {
Show 47 methods
// Required methods
fn set_endian(&mut self, endian: Endian);
fn endian(&self) -> Endian;
fn read_byte(&mut self) -> Result<u8, Error>;
fn read_u8(&mut self) -> Result<u8, Error>;
fn read_exact(&mut self, array: &mut [u8]) -> Result<(), Error>;
fn read_bytes_as_vec(&mut self, len: usize) -> Result<Vec<u8>, Error>;
fn read_bytes_no_move(&mut self, len: usize) -> Result<Vec<u8>, Error>;
fn read_u16(&mut self) -> Result<u16, Error>;
fn read_u32(&mut self) -> Result<u32, Error>;
fn read_u64(&mut self) -> Result<u64, Error>;
fn read_u128(&mut self) -> Result<u128, Error>;
fn read_i8(&mut self) -> Result<i8, Error>;
fn read_i16(&mut self) -> Result<i16, Error>;
fn read_i32(&mut self) -> Result<i32, Error>;
fn read_i64(&mut self) -> Result<i64, Error>;
fn read_i128(&mut self) -> Result<i128, Error>;
fn read_f32(&mut self) -> Result<f32, Error>;
fn read_f64(&mut self) -> Result<f64, Error>;
fn read_u16_be(&mut self) -> Result<u16, Error>;
fn read_u32_be(&mut self) -> Result<u32, Error>;
fn read_u64_be(&mut self) -> Result<u64, Error>;
fn read_u128_be(&mut self) -> Result<u128, Error>;
fn read_i16_be(&mut self) -> Result<i16, Error>;
fn read_i32_be(&mut self) -> Result<i32, Error>;
fn read_i64_be(&mut self) -> Result<i64, Error>;
fn read_i128_be(&mut self) -> Result<i128, Error>;
fn read_f32_be(&mut self) -> Result<f32, Error>;
fn read_f64_be(&mut self) -> Result<f64, Error>;
fn read_u16_le(&mut self) -> Result<u16, Error>;
fn read_u32_le(&mut self) -> Result<u32, Error>;
fn read_u64_le(&mut self) -> Result<u64, Error>;
fn read_u128_le(&mut self) -> Result<u128, Error>;
fn read_i16_le(&mut self) -> Result<i16, Error>;
fn read_i32_le(&mut self) -> Result<i32, Error>;
fn read_i64_le(&mut self) -> Result<i64, Error>;
fn read_i128_le(&mut self) -> Result<i128, Error>;
fn read_f32_le(&mut self) -> Result<f32, Error>;
fn read_f64_le(&mut self) -> Result<f64, Error>;
fn skip_ptr(&mut self, size: usize) -> Result<usize, Error>;
fn offset(&mut self) -> Result<u64, Error>;
fn seek(&mut self, seek: SeekFrom) -> Result<u64, Error>;
// Provided methods
fn read_bytes(&mut self, array: &mut [u8]) -> Result<(), Error> { ... }
fn read_ascii_string(&mut self, size: usize) -> Result<String, Error> { ... }
fn read_utf16_string(&mut self, size: usize) -> Result<String, Error> { ... }
fn read_utf16be_string(&mut self, size: usize) -> Result<String, Error> { ... }
fn read_utf16le_string(&mut self, size: usize) -> Result<String, Error> { ... }
fn read_utf8_string(&mut self, size: usize) -> Result<String, Error> { ... }
}Expand description
0.0.11 Some functions have been changed to be written in this trait.
Required Methods§
fn set_endian(&mut self, endian: Endian)
fn endian(&self) -> Endian
fn read_byte(&mut self) -> Result<u8, Error>
fn read_u8(&mut self) -> Result<u8, Error>
fn read_exact(&mut self, array: &mut [u8]) -> Result<(), Error>
fn read_bytes_as_vec(&mut self, len: usize) -> Result<Vec<u8>, Error>
Sourcefn read_bytes_no_move(&mut self, len: usize) -> Result<Vec<u8>, Error>
fn read_bytes_no_move(&mut self, len: usize) -> Result<Vec<u8>, Error>
read_bytes_no_move does not move offset after read_bytes.
Assumed to be used for header checks.
fn read_u16(&mut self) -> Result<u16, Error>
fn read_u32(&mut self) -> Result<u32, Error>
fn read_u64(&mut self) -> Result<u64, Error>
fn read_u128(&mut self) -> Result<u128, Error>
fn read_i8(&mut self) -> Result<i8, Error>
fn read_i16(&mut self) -> Result<i16, Error>
fn read_i32(&mut self) -> Result<i32, Error>
fn read_i64(&mut self) -> Result<i64, Error>
fn read_i128(&mut self) -> Result<i128, Error>
fn read_f32(&mut self) -> Result<f32, Error>
fn read_f64(&mut self) -> Result<f64, Error>
fn read_u16_be(&mut self) -> Result<u16, Error>
fn read_u32_be(&mut self) -> Result<u32, Error>
fn read_u64_be(&mut self) -> Result<u64, Error>
fn read_u128_be(&mut self) -> Result<u128, Error>
fn read_i16_be(&mut self) -> Result<i16, Error>
fn read_i32_be(&mut self) -> Result<i32, Error>
fn read_i64_be(&mut self) -> Result<i64, Error>
fn read_i128_be(&mut self) -> Result<i128, Error>
fn read_f32_be(&mut self) -> Result<f32, Error>
fn read_f64_be(&mut self) -> Result<f64, Error>
fn read_u16_le(&mut self) -> Result<u16, Error>
fn read_u32_le(&mut self) -> Result<u32, Error>
fn read_u64_le(&mut self) -> Result<u64, Error>
fn read_u128_le(&mut self) -> Result<u128, Error>
fn read_i16_le(&mut self) -> Result<i16, Error>
fn read_i32_le(&mut self) -> Result<i32, Error>
fn read_i64_le(&mut self) -> Result<i64, Error>
fn read_i128_le(&mut self) -> Result<i128, Error>
fn read_f32_le(&mut self) -> Result<f32, Error>
fn read_f64_le(&mut self) -> Result<f64, Error>
fn offset(&mut self) -> Result<u64, Error>
fn seek(&mut self, seek: SeekFrom) -> Result<u64, Error>
Provided Methods§
fn read_bytes(&mut self, array: &mut [u8]) -> Result<(), Error>
👎Deprecated since 0.0.10:
Use new function read_exact() instead
Sourcefn read_ascii_string(&mut self, size: usize) -> Result<String, Error>
fn read_ascii_string(&mut self, size: usize) -> Result<String, Error>
read_ascii_string for C like ascii string.This function finishes find end marker 0x00.
use bin_rs::reader::*;
use std::io::Error;
fn test() -> Result<String,Error> {
let buffer = b"Hello World!\01234";
let mut reader = BytesReader::new(buffer);
let r = reader.read_ascii_string("Hello World!\01234".len())?; // after \0 is trim
//assert_eq!(r ,"Hello World!");
return Ok(r)
}Sourcefn read_utf16_string(&mut self, size: usize) -> Result<String, Error>
fn read_utf16_string(&mut self, size: usize) -> Result<String, Error>
0.0.11 read_utf16_string for utf16 string. use endien “size” refers to the number of bytes.