pub trait BinReaderExt:
Read
+ Seek
+ Sized {
// Provided methods
fn read_type<'a, T>(&mut self, endian: Endian) -> BinResult<T>
where T: BinRead,
T::Args<'a>: Required { ... }
fn read_be<'a, T>(&mut self) -> BinResult<T>
where T: BinRead,
T::Args<'a>: Required { ... }
fn read_le<'a, T>(&mut self) -> BinResult<T>
where T: BinRead,
T::Args<'a>: Required { ... }
fn read_ne<'a, T>(&mut self) -> BinResult<T>
where T: BinRead,
T::Args<'a>: Required { ... }
fn read_type_args<T>(
&mut self,
endian: Endian,
args: T::Args<'_>,
) -> BinResult<T>
where T: BinRead { ... }
fn read_be_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>
where T: BinRead { ... }
fn read_le_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>
where T: BinRead { ... }
fn read_ne_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>
where T: BinRead { ... }
}Expand description
Extension methods for reading BinRead objects directly from a reader.
§Examples
use binrw::{BinReaderExt, Endian, 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(Endian::Little).unwrap();
let z = reader.read_be::<u16>().unwrap();
assert_eq!((x, y, z), (7u32, 0xCCu16, 5u16));Provided Methods§
Sourcefn read_type_args<T>(
&mut self,
endian: Endian,
args: T::Args<'_>,
) -> BinResult<T>where
T: BinRead,
fn read_type_args<T>(
&mut self,
endian: Endian,
args: T::Args<'_>,
) -> BinResult<T>where
T: BinRead,
Sourcefn read_be_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>where
T: BinRead,
fn read_be_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>where
T: BinRead,
Sourcefn read_le_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>where
T: BinRead,
fn read_le_args<T>(&mut self, args: T::Args<'_>) -> BinResult<T>where
T: BinRead,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.