1use core::fmt;
2use core::num::NonZeroU64;
3
4#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6pub struct NodeId(NonZeroU64);
7
8impl NodeId {
9 pub(crate) fn from_index(index: u64) -> Self {
10 let value = NonZeroU64::new(index).expect("node ids start at 1");
11 Self(value)
12 }
13
14 pub fn get(self) -> u64 {
16 self.0.get()
17 }
18}
19
20impl fmt::Debug for NodeId {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 write!(f, "NodeId({})", self.get())
23 }
24}
25
26#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
28pub struct ScopeId(NonZeroU64);
29
30impl ScopeId {
31 pub(crate) fn from_index(index: u64) -> Self {
32 let value = NonZeroU64::new(index).expect("scope ids start at 1");
33 Self(value)
34 }
35
36 pub fn get(self) -> u64 {
38 self.0.get()
39 }
40}
41
42impl fmt::Debug for ScopeId {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 write!(f, "ScopeId({})", self.get())
45 }
46}
47
48#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
50pub struct OutputKey(NonZeroU64);
51
52impl OutputKey {
53 pub(crate) fn from_index(index: u64) -> Self {
54 let value = NonZeroU64::new(index).expect("output keys start at 1");
55 Self(value)
56 }
57
58 pub fn get(self) -> u64 {
60 self.0.get()
61 }
62}
63
64impl fmt::Debug for OutputKey {
65 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
66 write!(f, "OutputKey({})", self.get())
67 }
68}
69
70#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
72pub struct Revision(u64);
73
74impl Revision {
75 pub const fn new(value: u64) -> Self {
77 Self(value)
78 }
79
80 pub const fn get(self) -> u64 {
82 self.0
83 }
84
85 pub(crate) const fn next(self) -> Self {
86 Self(self.0 + 1)
87 }
88}
89
90#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
92pub struct TransactionId(u64);
93
94impl TransactionId {
95 pub const fn new(value: u64) -> Self {
97 Self(value)
98 }
99
100 pub const fn get(self) -> u64 {
102 self.0
103 }
104
105 pub(crate) const fn next(self) -> Self {
106 Self(self.0 + 1)
107 }
108}