Struct binrw::FilePtr [−][src]
A wrapper type which represents a layer of indirection within a file.
FilePtr<P, T> is composed of two types. The pointer type P is the
absolute offset to a value within the data, and the value type T is
the actual pointed-to value. Once a FilePtr has been
finalized, dereferencing it will yield the
pointed-to value.
When deriving BinRead, offset directives
can be used to adjust the offset before the pointed-to value is read.
Examples
#[derive(BinRead)] struct Test { indirect_value: FilePtr<u32, u8> } let test: Test = Cursor::new(b"\0\0\0\x08\0\0\0\0\xff").read_be().unwrap(); assert_eq!(test.indirect_value.ptr, 8); assert_eq!(*test.indirect_value, 0xFF);
Example data mapped out:
[pointer] [value]
00000000: 0000 0008 0000 0000 ff ............
Fields
ptr: PtrThe raw offset to the value.
value: Option<BR>The pointed-to value.
Implementations
impl<Ptr: BinRead<Args = ()> + IntoSeekFrom, BR: BinRead> FilePtr<Ptr, BR>[src]
pub fn parse<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: BR::Args
) -> BinResult<BR>[src]
reader: &mut R,
options: &ReadOptions,
args: BR::Args
) -> BinResult<BR>
Custom parser for use with the
parse_with directive that reads
and then immediately finalizes a FilePtr, returning the pointed-to
value as the result.
pub fn into_inner(self) -> BR[src]
Consumes this object, returning the pointed-to value.
Panics
Will panic if FilePtr hasn’t been finalized by calling
after_parse().
Trait Implementations
impl<Ptr: BinRead<Args = ()> + IntoSeekFrom, BR: BinRead> BinRead for FilePtr<Ptr, BR>[src]
type Args = BR::Args
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,
_: Self::Args
) -> BinResult<Self>[src]
reader: &mut R,
options: &ReadOptions,
_: Self::Args
) -> BinResult<Self>
Reads the offset of the value from the reader.
The actual value will not be read until
after_parse() is called.
fn after_parse<R>(
&mut self,
reader: &mut R,
ro: &ReadOptions,
args: BR::Args
) -> BinResult<()> where
R: Read + Seek, [src]
&mut self,
reader: &mut R,
ro: &ReadOptions,
args: BR::Args
) -> BinResult<()> where
R: Read + Seek,
Finalizes the FilePtr by seeking to and reading the pointed-to value.
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self> where
Self::Args: Default, [src]
Self::Args: Default,
fn read_args<R: Read + Seek>(
reader: &mut R,
args: Self::Args
) -> BinResult<Self>[src]
reader: &mut R,
args: Self::Args
) -> BinResult<Self>
impl<Ptr, BR> Debug for FilePtr<Ptr, BR> where
Ptr: BinRead<Args = ()> + IntoSeekFrom,
BR: BinRead + Debug, [src]
Ptr: BinRead<Args = ()> + IntoSeekFrom,
BR: BinRead + Debug,
impl<Ptr: IntoSeekFrom, BR: BinRead> Deref for FilePtr<Ptr, BR>[src]
Dereferences the value.
Panics
Will panic if FilePtr hasn’t been finalized by calling
after_parse().
impl<Ptr: IntoSeekFrom, BR: BinRead> DerefMut for FilePtr<Ptr, BR>[src]
Panics
Will panic if the FilePtr has not been read yet using BinRead::after_parse
impl<Ptr, BR> PartialEq<FilePtr<Ptr, BR>> for FilePtr<Ptr, BR> where
Ptr: BinRead<Args = ()> + IntoSeekFrom,
BR: BinRead + PartialEq, [src]
Ptr: BinRead<Args = ()> + IntoSeekFrom,
BR: BinRead + PartialEq,
Auto Trait Implementations
impl<Ptr, BR> RefUnwindSafe for FilePtr<Ptr, BR> where
BR: RefUnwindSafe,
Ptr: RefUnwindSafe,
BR: RefUnwindSafe,
Ptr: RefUnwindSafe,
impl<Ptr, BR> Send for FilePtr<Ptr, BR> where
BR: Send,
Ptr: Send,
BR: Send,
Ptr: Send,
impl<Ptr, BR> Sync for FilePtr<Ptr, BR> where
BR: Sync,
Ptr: Sync,
BR: Sync,
Ptr: Sync,
impl<Ptr, BR> Unpin for FilePtr<Ptr, BR> where
BR: Unpin,
Ptr: Unpin,
BR: Unpin,
Ptr: Unpin,
impl<Ptr, BR> UnwindSafe for FilePtr<Ptr, BR> where
BR: UnwindSafe,
Ptr: UnwindSafe,
BR: UnwindSafe,
Ptr: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut Tⓘ[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,