1use crate::{Bytes, Result};
2
3#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
7#[must_use = "Stamp values should be used for tracking"]
8pub struct Stamp(u64);
9
10impl Stamp {
11 pub fn new(stamp: u64) -> Self {
12 Self(stamp)
13 }
14}
15
16impl From<u64> for Stamp {
17 fn from(value: u64) -> Self {
18 Self(value)
19 }
20}
21
22impl From<Stamp> for u64 {
23 fn from(value: Stamp) -> Self {
24 value.0
25 }
26}
27
28impl Bytes for Stamp {
29 type Array = [u8; size_of::<Self>()];
30
31 #[inline]
32 fn to_bytes(&self) -> Self::Array {
33 self.0.to_bytes()
34 }
35
36 #[inline]
37 fn from_bytes(bytes: &[u8]) -> Result<Self> {
38 Ok(Self(u64::from_bytes(bytes)?))
39 }
40}