Trait binrw::prelude::BinReaderExt [−][src]
pub trait BinReaderExt: Read + Seek + Sized {
fn read_type<T: BinRead>(&mut self, endian: Endian) -> BinResult<T>
where
T::Args: Default,
{ ... }
fn read_be<T: BinRead>(&mut self) -> BinResult<T>
where
T::Args: Default,
{ ... }
fn read_le<T: BinRead>(&mut self) -> BinResult<T>
where
T::Args: Default,
{ ... }
fn read_ne<T: BinRead>(&mut self) -> BinResult<T>
where
T::Args: Default,
{ ... }
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
Extension methods for reading BinRead
objects directly from a reader.
Examples
use binrw::BinReaderExt;
use binrw::endian::LE;
use binrw::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 T
from the reader with the given byte order.
Read T
from the reader assuming big-endian byte order.
Read T
from the reader assuming little-endian byte order.
Read T
from the reader assuming native-endian byte order.
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.