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§
source§impl<T: BinRead> BinRead for PosValue<T>
impl<T: BinRead> BinRead for PosValue<T>
source§fn read_options<R: Read + Seek>(
reader: &mut R,
endian: Endian,
args: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, endian: Endian, args: Self::Args<'_>, ) -> BinResult<Self>
source§fn read_be_args<R: Read + Seek>(
reader: &mut R,
args: Self::Args<'_>,
) -> BinResult<Self>
fn read_be_args<R: Read + Seek>( reader: &mut R, args: Self::Args<'_>, ) -> BinResult<Self>
Read
Self
from the reader, assuming big-endian byte order, using the
given arguments. Read moreAuto Trait Implementations§
impl<T> Freeze for PosValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for PosValue<T>where
T: RefUnwindSafe,
impl<T> Send for PosValue<T>where
T: Send,
impl<T> Sync for PosValue<T>where
T: Sync,
impl<T> Unpin for PosValue<T>where
T: Unpin,
impl<T> UnwindSafe for PosValue<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more