[−][src]Struct binread::file_ptr::FilePtr
A wrapper type for representing a layer of indirection within a file.
A FilePtr<P, T>
is composed of two types: a pointer type P
and a value type T
where
the pointer type describes and offset to read the value type from. Once read from the file
it can be dereferenced to yeild the value it points to.
Example
use binread::{prelude::*, io::Cursor, FilePtr}; #[derive(BinRead)] struct Test { pointer: FilePtr<u32, u8> } fn main() { let test: Test = Cursor::new(b"\0\0\0\x08\0\0\0\0\xff").read_be().unwrap(); assert_eq!(test.pointer.ptr, 8); assert_eq!(*test.pointer, 0xFF); }
Example data mapped out:
[pointer] [value]
00000000: 0000 0008 0000 0000 ff ............
Use offset
to change what the pointer is relative to (default: beginning of reader).
Fields
ptr: Ptr
value: Option<BR>
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 designed for use with the parse_with
attribute (example)
that reads a FilePtr
then immediately dereferences it into an owned value
pub fn into_inner(self) -> BR
[src]
Consume the pointer and return the inner type
Panics
Will panic if the file pointer hasn't been properly postprocessed
Trait Implementations
impl<Ptr: BinRead<Args = ()> + IntoSeekFrom, BR: BinRead> BinRead for FilePtr<Ptr, BR>
[src]
type Args = BR::Args
The type of arguments needed to be supplied in order to read this type, usually a tuple. 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>
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,
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
[src]
fn read_args<R: Read + Seek>(
reader: &mut R,
args: Self::Args
) -> BinResult<Self>
[src]
reader: &mut R,
args: Self::Args
) -> BinResult<Self>
fn args_default() -> Option<Self::Args>
[src]
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]
Panics
Will panic if the FilePtr has not been read yet using BinRead::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,
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.
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>,