pub trait ReadBytesAtExt: ReadAt {
    // Provided methods
    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> { ... }
}
Expand description

Extends ReadAt with methods for reading numbers at offsets.

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

Examples

Read an integer from the middle of a byte array:

use byteorder::BigEndian;
use positioned_io::ReadBytesAtExt;

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

Provided Methods§

source

fn read_u8_at(&self, pos: u64) -> Result<u8>

Reads an unsigned 8-bit integer at an offset.

source

fn read_i8_at(&self, pos: u64) -> Result<i8>

Reads a signed 8-bit integer at an offset.

source

fn read_u16_at<T: ByteOrder>(&self, pos: u64) -> Result<u16>

Reads an unsigned 16-bit integer at an offset.

source

fn read_i16_at<T: ByteOrder>(&self, pos: u64) -> Result<i16>

Reads a signed 16-bit integer at an offset.

source

fn read_u32_at<T: ByteOrder>(&self, pos: u64) -> Result<u32>

Reads an unsigned 32-bit integer at an offset.

source

fn read_i32_at<T: ByteOrder>(&self, pos: u64) -> Result<i32>

Reads a signed 32-bit integer at an offset.

source

fn read_u64_at<T: ByteOrder>(&self, pos: u64) -> Result<u64>

Reads an unsigned 64-bit integer at an offset.

source

fn read_i64_at<T: ByteOrder>(&self, pos: u64) -> Result<i64>

Reads a signed 64-bit integer at an offset.

source

fn read_uint_at<T: ByteOrder>(&self, pos: u64, nbytes: usize) -> Result<u64>

Reads an unsigned nbytes-bit integer at an offset.

source

fn read_int_at<T: ByteOrder>(&self, pos: u64, nbytes: usize) -> Result<i64>

Reads a signed nbytes-bit integer at an offset.

source

fn read_f32_at<T: ByteOrder>(&self, pos: u64) -> Result<f32>

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

source

fn read_f64_at<T: ByteOrder>(&self, pos: u64) -> Result<f64>

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

Object Safety§

This trait is not object safe.

Implementors§