1use moire_trace_types::JS_SAFE_INT_MAX_U64;
2pub use moire_types::ConnectionId;
3use moire_types::CutId;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct SessionOrdinal(u64);
7
8impl SessionOrdinal {
9 pub const ONE: Self = Self(1);
10
11 pub fn to_session_id(self) -> moire_types::SessionId {
12 moire_types::SessionId::from_ordinal(self.0)
13 }
14
15 pub fn next(self) -> Self {
16 let next = self.0.saturating_add(1);
17 assert!(
18 next > 0 && next <= JS_SAFE_INT_MAX_U64,
19 "invariant violated: session ordinal must be in 1..={JS_SAFE_INT_MAX_U64}, got {next}"
20 );
21 Self(next)
22 }
23}
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
26pub struct CutOrdinal(u64);
27
28impl CutOrdinal {
29 pub const ONE: Self = Self(1);
30
31 pub fn to_cut_id(self) -> CutId {
32 CutId::from_ordinal(self.0)
33 }
34
35 pub fn next(self) -> Self {
36 let next = self.0.saturating_add(1);
37 assert!(
38 next > 0 && next <= JS_SAFE_INT_MAX_U64,
39 "invariant violated: cut ordinal must be in 1..={JS_SAFE_INT_MAX_U64}, got {next}"
40 );
41 Self(next)
42 }
43}