Struct binrw::PosValue[][src]

pub struct PosValue<T> {
    pub val: T,
    pub pos: u64,
}
Expand description

A wrapper that stores a value’s position alongside the value.

Examples

use binrw::{BinRead, PosValue, BinReaderExt, io::Cursor};

#[derive(BinRead)]
struct MyType {
    a: u16,
    b: PosValue<u8>
}

let val = Cursor::new(b"\xFF\xFE\xFD").read_be::<MyType>().unwrap();
assert_eq!(val.b.pos, 2);
assert_eq!(*val.b, 0xFD);

Fields

val: T

The read value.

pos: u64

The byte position of the start of the value.

Trait Implementations

The type used for the args parameter of read_args() and read_options(). Read more

Read Self from the reader using the given ReadOptions and arguments. Read more

Runs any post-processing steps required to finalize construction of the object. Read more

Read Self from the reader using default arguments.

Read Self from the reader using the given arguments.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.