[−][src]Module binread::file_ptr
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 an offset to read the value type from. Once read from the file
it can be dereferenced to yield 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).
Structs
FilePtr | A wrapper type for representing a layer of indirection within a file. |
Traits
IntoSeekFrom | Used to allow any convert any type castable to i64 into a |
Type Definitions
FilePtr8 | Type alias for 8-bit pointers |
FilePtr16 | Type alias for 16-bit pointers |
FilePtr32 | Type alias for 32-bit pointers |
FilePtr64 | Type alias for 64-bit pointers |
FilePtr128 | Type alias for 128-bit pointers |