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> { ... } }

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

fn read_type<T: BinRead>(&mut self, endian: Endian) -> BinResult<T>[src]

Read the given type from the reader using the given endianness.

fn read_be<T: BinRead>(&mut self) -> BinResult<T>[src]

Read the given type from the reader with big endian byteorder

fn read_le<T: BinRead>(&mut self) -> BinResult<T>[src]

Read the given type from the reader with little endian byteorder

fn read_ne<T: BinRead>(&mut self) -> BinResult<T>[src]

Read the given type from the reader with the native byteorder

Loading content...

Implementors

impl<R: Read + Seek + Sized> BinReaderExt for R[src]

Loading content...