pub struct BytesReader { /* private fields */ }Expand description
BytesReader from creating Slice &[u8] or Vec<u8>,
no use Read trait
Implementations§
Trait Implementations§
Source§impl BinaryReader for BytesReader
impl BinaryReader for BytesReader
Source§fn 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>
use bin_rs::reader::*;
use std::io::Error;
fn test() -> Result<(),Error> {
let buffer = b"Hello World!";
let mut reader = BytesReader::new(buffer);
let buffer1 = reader.read_bytes_no_move(4)?;
// assert_eq!(buffer1,b"Hell");
let buffer1 = reader.read_bytes_as_vec(4)?;
// assert_eq!(buffer1,b"Hell");
let buffer1 = reader.read_bytes_as_vec(4)?;
// assert_eq!(buffer1,b"o Wo");
return Ok(())
}fn offset(&mut self) -> Result<u64, Error>
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_i8(&mut self) -> Result<i8, 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_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_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 seek(&mut self, seek: SeekFrom) -> Result<u64, Error>
Source§fn read_bytes(&mut self, array: &mut [u8]) -> Result<(), Error>
fn read_bytes(&mut self, array: &mut [u8]) -> Result<(), Error>
👎Deprecated since 0.0.10:
Use new function read_exact() instead
Source§fn 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. Read more
Source§fn 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.
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>
Source§impl Clone for BytesReader
impl Clone for BytesReader
Source§fn clone(&self) -> BytesReader
fn clone(&self) -> BytesReader
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 moreSource§impl Debug for BytesReader
impl Debug for BytesReader
Source§impl From<&[u8]> for BytesReader
impl From<&[u8]> for BytesReader
Auto Trait Implementations§
impl Freeze for BytesReader
impl RefUnwindSafe for BytesReader
impl Send for BytesReader
impl Sync for BytesReader
impl Unpin for BytesReader
impl UnsafeUnpin for BytesReader
impl UnwindSafe for BytesReader
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