[−][src]Trait binread::BinReaderExt
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 std::io::Cursor; fn main() { 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
fn read_type<T: BinRead>(&mut self, endian: Endian) -> BinResult<T>
Read the given type from the reader using the given endianness.
fn read_be<T: BinRead>(&mut self) -> BinResult<T>
Read the given type from the reader with big endian byteorder
fn read_le<T: BinRead>(&mut self) -> BinResult<T>
Read the given type from the reader with little endian byteorder
fn read_ne<T: BinRead>(&mut self) -> BinResult<T>
Read the given type from the reader with the native byteorder