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: T
§pos: u64
Trait Implementations§
source§impl<T: BinRead> BinRead for PosValue<T>
impl<T: BinRead> BinRead for PosValue<T>
source§type Args = <T as BinRead>::Args
type Args = <T as BinRead>::Args
The type of arguments needed to be supplied in order to read this type, usually a tuple. Read more
source§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 the type from the reader
fn after_parse<R: Read + Seek>( &mut self, reader: &mut R, options: &ReadOptions, args: Self::Args, ) -> BinResult<()>
source§fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
Read the type from the reader while assuming no arguments have been passed Read more
Auto 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)