1#[repr(transparent)]
5#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
6pub struct EndpointId(u64);
7
8impl EndpointId {
9 pub const fn new(value: u64) -> Self {
11 Self(value)
12 }
13
14 pub const fn get(self) -> u64 {
16 self.0
17 }
18}
19
20#[repr(transparent)]
22#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct LaneId(u32);
24
25impl LaneId {
26 pub const fn new(value: u32) -> Self {
28 Self(value)
29 }
30
31 pub const fn get(self) -> u32 {
33 self.0
34 }
35}
36
37#[repr(transparent)]
39#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct ConnectionId(u64);
41
42impl ConnectionId {
43 pub const fn new(value: u64) -> Self {
45 Self(value)
46 }
47
48 pub const fn get(self) -> u64 {
50 self.0
51 }
52}
53
54#[repr(transparent)]
56#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct ConnectionEpoch(u64);
58
59impl ConnectionEpoch {
60 pub const fn new(value: u64) -> Self {
62 Self(value)
63 }
64
65 pub const fn get(self) -> u64 {
67 self.0
68 }
69}
70
71#[repr(transparent)]
73#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74pub struct OperationId(u64);
75
76impl OperationId {
77 pub const fn new(value: u64) -> Self {
79 Self(value)
80 }
81
82 pub const fn get(self) -> u64 {
84 self.0
85 }
86}
87
88#[repr(transparent)]
90#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91pub struct EffectId(u64);
92
93impl EffectId {
94 pub const fn new(value: u64) -> Self {
96 Self(value)
97 }
98
99 pub const fn get(self) -> u64 {
101 self.0
102 }
103}
104
105#[repr(transparent)]
107#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108pub struct MatchKey(u32);
109
110impl MatchKey {
111 pub const fn new(value: u32) -> Self {
113 Self(value)
114 }
115
116 pub const fn get(self) -> u32 {
118 self.0
119 }
120}
121
122#[derive(Clone, Copy, Debug, Eq, PartialEq)]
124pub struct IdentitySeeds {
125 operation: u64,
126 effect: u64,
127}
128
129impl IdentitySeeds {
130 pub const ZERO: Self = Self::new(0, 0);
132
133 pub const fn new(operation: u64, effect: u64) -> Self {
135 Self { operation, effect }
136 }
137
138 pub const fn operation(self) -> u64 {
140 self.operation
141 }
142
143 pub const fn effect(self) -> u64 {
145 self.effect
146 }
147}
148
149#[derive(Debug)]
150pub(crate) struct IdentityGenerator {
151 operation: Option<u64>,
152 effect: Option<u64>,
153}
154
155impl IdentityGenerator {
156 pub(crate) const fn new(seeds: IdentitySeeds) -> Self {
157 Self {
158 operation: Some(seeds.operation()),
159 effect: Some(seeds.effect()),
160 }
161 }
162
163 pub(crate) const fn available(&self) -> bool {
164 self.operation.is_some() && self.effect.is_some()
165 }
166
167 pub(crate) fn take(&mut self) -> Option<(OperationId, EffectId)> {
168 let operation = self.operation?;
169 let effect = self.effect?;
170 self.operation = operation.checked_add(1);
171 self.effect = effect.checked_add(1);
172 Some((OperationId::new(operation), EffectId::new(effect)))
173 }
174}