1#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct SegmentId(pub u64);
8
9impl SegmentId {
10 pub const fn new(id: u64) -> Self {
11 Self(id)
12 }
13
14 pub const fn as_u64(self) -> u64 {
15 self.0
16 }
17}
18
19impl std::fmt::Display for SegmentId {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 write!(f, "{}", self.0)
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28
29 #[test]
30 fn ordering() {
31 assert!(SegmentId(0) < SegmentId(1));
32 }
33
34 #[test]
35 fn as_u64_round_trips() {
36 assert_eq!(SegmentId::new(999).as_u64(), 999);
37 }
38}