Trait positioned_io::ReadBytesExt [] [src]

pub trait ReadBytesExt: ReadAt {
    fn read_u8_at(&self, pos: u64) -> Result<u8> { ... }
    fn read_i8_at(&self, pos: u64) -> Result<i8> { ... }
    fn read_u16_at<T: ByteOrder>(&self, pos: u64) -> Result<u16> { ... }
    fn read_i16_at<T: ByteOrder>(&self, pos: u64) -> Result<i16> { ... }
    fn read_u32_at<T: ByteOrder>(&self, pos: u64) -> Result<u32> { ... }
    fn read_i32_at<T: ByteOrder>(&self, pos: u64) -> Result<i32> { ... }
    fn read_u64_at<T: ByteOrder>(&self, pos: u64) -> Result<u64> { ... }
    fn read_i64_at<T: ByteOrder>(&self, pos: u64) -> Result<i64> { ... }
    fn read_uint_at<T: ByteOrder>(&self, pos: u64, nbytes: usize) -> Result<u64> { ... }
    fn read_int_at<T: ByteOrder>(&self, pos: u64, nbytes: usize) -> Result<i64> { ... }
    fn read_f32_at<T: ByteOrder>(&self, pos: u64) -> Result<f32> { ... }
    fn read_f64_at<T: ByteOrder>(&self, pos: u64) -> Result<f64> { ... }
}

Extends ReadAt with methods for reading numbers at offsets.

For most of these methods, you need to explicitly add a ByteOrder type parameter. See byteorder::ReadBytesExt.

Examples

Read an integer from the middle of a byte array:

use positioned_io::ReadBytesExt;

let buf = [0, 5, 254, 212, 0, 3];
let n = try!(buf.as_ref().read_i16_at::<BigEndian>(2));
assert_eq!(n, -300);

Provided Methods

Reads an unsigned 8-bit integer at an offset.

Reads a signed 8-bit integer at an offset.

Reads an unsigned 16-bit integer at an offset.

Reads a signed 16-bit integer at an offset.

Reads an unsigned 32-bit integer at an offset.

Reads a signed 32-bit integer at an offset.

Reads an unsigned 64-bit integer at an offset.

Reads a signed 64-bit integer at an offset.

Reads an unsigned nbytes-bit integer at an offset.

Reads a signed nbytes-bit integer at an offset.

Reads a single-precision floating point number at an offset.

Reads a double-precision floating point number at an offset.

Implementors