Expand description
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>
}
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§
- A wrapper type for representing a layer of indirection within a file.
Traits§
- Used to allow any convert any type castable to i64 into a
SeekFrom::Current
Type Aliases§
- Type alias for 8-bit pointers
- Type alias for 16-bit pointers
- Type alias for 32-bit pointers
- Type alias for 64-bit pointers
- Type alias for 128-bit pointers