Trait binread::BinReaderExt [−][src]
pub trait BinReaderExt: Read + Seek + Sized {
fn read_type<T: BinRead>(&mut self, endian: Endian) -> BinResult<T> { ... }
fn read_be<T: BinRead>(&mut self) -> BinResult<T> { ... }
fn read_le<T: BinRead>(&mut self) -> BinResult<T> { ... }
fn read_ne<T: BinRead>(&mut self) -> BinResult<T> { ... }
fn read_type_args<T: BinRead>(
&mut self,
endian: Endian,
args: T::Args
) -> BinResult<T> { ... }
fn read_be_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T> { ... }
fn read_le_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T> { ... }
fn read_ne_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T> { ... }
}
Expand description
An extension trait for io::Read
to provide methods for reading a value directly
Example
use binread::prelude::*; // BinReadExt is in the prelude
use binread::endian::LE;
use binread::io::Cursor;
let mut reader = Cursor::new(b"\x07\0\0\0\xCC\0\0\x05");
let x: u32 = reader.read_le().unwrap();
let y: u16 = reader.read_type(LE).unwrap();
let z = reader.read_be::<u16>().unwrap();
assert_eq!((x, y, z), (7u32, 0xCCu16, 5u16));
Provided methods
Read the given type from the reader using the given endianness.
Read the given type from the reader with big endian byteorder
Read the given type from the reader with little endian byteorder
Read the given type from the reader with the native byteorder
Read T
from the reader with the given byte order and arguments.
fn read_be_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
fn read_be_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
Read T
from the reader, assuming big-endian byte order, using the
given arguments.
fn read_le_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
fn read_le_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
Read T
from the reader, assuming little-endian byte order, using the
given arguments.
fn read_ne_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
fn read_ne_args<T: BinRead>(&mut self, args: T::Args) -> BinResult<T>
Read T
from the reader, assuming native-endian byte order, using the
given arguments.