Struct binread::PosValue[][src]

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

A wrapper where the position it was read from is stored alongside the value

use binread::{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: Tpos: u64

Trait Implementations

The type of arguments needed to be supplied in order to read this type, usually a tuple. Read more

Read the type from the reader

Read the type from the reader while assuming no arguments have been passed Read more

Read the type from the reader using the specified arguments

The default arguments to be used when using the read shortcut method. Override this for any type that optionally requries arguments Read more

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)

recently added

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.