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
fn read_options<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: T::Args
) -> BinResult<Self>
fn read_options<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: T::Args
) -> BinResult<Self>
Read Self
from the reader using the given ReadOptions
and
arguments. Read more
fn after_parse<R: Read + Seek>(
&mut self,
reader: &mut R,
options: &ReadOptions,
args: Self::Args
) -> BinResult<()>
fn after_parse<R: Read + Seek>(
&mut self,
reader: &mut R,
options: &ReadOptions,
args: Self::Args
) -> BinResult<()>
Runs any post-processing steps required to finalize construction of the object. Read more
Read Self
from the reader using default arguments.
Auto Trait Implementations
impl<T> RefUnwindSafe for PosValue<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for PosValue<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more