1use crate::prelude::{Reading, Result};
2
3#[derive(Clone, Copy, Default, PartialEq, PartialOrd)]
4pub struct Offset(pub u64);
5
6impl std::ops::Deref for Offset {
7 type Target = u64;
8 fn deref(&self) -> &Self::Target {
9 &self.0
10 }
11}
12
13impl std::fmt::Debug for Offset {
14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 f.write_fmt(format_args!("@{:#010X}", self.0))
16 }
17}
18
19impl<T> Reading<Offset> for T
20where
21 T: Reading<u32>,
22{
23 const SIZE: usize = <T as Reading<u32>>::SIZE;
24
25 fn read_one(&mut self) -> Result<Offset> {
26 self.read_one().map(u64::from).map(Offset)
27 }
28}