Trait byteorder::ReadBytesExt [] [src]

pub trait ReadBytesExt: Read {
    fn read_u8(&mut self) -> Result<u8> { ... }
    fn read_i8(&mut self) -> Result<i8> { ... }
    fn read_u16<T: ByteOrder>(&mut self) -> Result<u16> { ... }
    fn read_i16<T: ByteOrder>(&mut self) -> Result<i16> { ... }
    fn read_u32<T: ByteOrder>(&mut self) -> Result<u32> { ... }
    fn read_i32<T: ByteOrder>(&mut self) -> Result<i32> { ... }
    fn read_u64<T: ByteOrder>(&mut self) -> Result<u64> { ... }
    fn read_i64<T: ByteOrder>(&mut self) -> Result<i64> { ... }
    fn read_uint<T: ByteOrder>(&mut self, nbytes: usize) -> Result<u64> { ... }
    fn read_int<T: ByteOrder>(&mut self, nbytes: usize) -> Result<i64> { ... }
    fn read_f32<T: ByteOrder>(&mut self) -> Result<f32> { ... }
    fn read_f64<T: ByteOrder>(&mut self) -> Result<f64> { ... }
}

Extends Read with methods for reading numbers. (For std::io.)

Most of the methods defined here have an unconstrained type parameter that must be explicitly instantiated. Typically, it is instantiated with either the BigEndian or LittleEndian types defined in this crate.

Examples

Read unsigned 16 bit big-endian integers from a Read:

use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt};

let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());

Provided Methods

Reads an unsigned 8 bit integer from the underlying reader.

Note that since this reads a single byte, no byte order conversions are used. It is included for completeness.

Reads a signed 8 bit integer from the underlying reader.

Note that since this reads a single byte, no byte order conversions are used. It is included for completeness.

Reads an unsigned 16 bit integer from the underlying reader.

Reads a signed 16 bit integer from the underlying reader.

Reads an unsigned 32 bit integer from the underlying reader.

Reads a signed 32 bit integer from the underlying reader.

Reads an unsigned 64 bit integer from the underlying reader.

Reads a signed 64 bit integer from the underlying reader.

Reads an unsigned n-bytes integer from the underlying reader.

Reads a signed n-bytes integer from the underlying reader.

Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader.

Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader.

Implementors