1use std::fmt;
6
7#[derive(Clone, Copy, PartialEq, Eq, Hash)]
12pub struct FeedId(u64);
13
14impl FeedId {
15 #[must_use]
20 pub fn new(val: u64) -> Self {
21 Self(val)
22 }
23
24 #[must_use]
26 pub fn as_u64(self) -> u64 {
27 self.0
28 }
29}
30
31impl fmt::Display for FeedId {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "feed-{}", self.0)
34 }
35}
36
37impl fmt::Debug for FeedId {
38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39 write!(f, "FeedId({})", self.0)
40 }
41}
42
43#[derive(Clone, Copy, PartialEq, Eq, Hash)]
48pub struct TrackId(u64);
49
50impl TrackId {
51 #[must_use]
53 pub fn new(val: u64) -> Self {
54 Self(val)
55 }
56
57 #[must_use]
59 pub fn as_u64(self) -> u64 {
60 self.0
61 }
62}
63
64impl fmt::Display for TrackId {
65 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
66 write!(f, "track-{}", self.0)
67 }
68}
69
70impl fmt::Debug for TrackId {
71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72 write!(f, "TrackId({})", self.0)
73 }
74}
75
76#[derive(Clone, Copy, PartialEq, Eq, Hash)]
81pub struct DetectionId(u64);
82
83impl DetectionId {
84 #[must_use]
86 pub fn new(val: u64) -> Self {
87 Self(val)
88 }
89
90 #[must_use]
92 pub fn as_u64(self) -> u64 {
93 self.0
94 }
95}
96
97impl fmt::Display for DetectionId {
98 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
99 write!(f, "det-{}", self.0)
100 }
101}
102
103impl fmt::Debug for DetectionId {
104 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
105 write!(f, "DetectionId({})", self.0)
106 }
107}
108
109#[derive(Clone, Copy, PartialEq, Eq, Hash)]
116pub struct StageId(pub &'static str);
117
118impl StageId {
119 #[must_use]
121 pub fn as_str(self) -> &'static str {
122 self.0
123 }
124}
125
126impl fmt::Display for StageId {
127 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
128 f.write_str(self.0)
129 }
130}
131
132impl fmt::Debug for StageId {
133 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134 write!(f, "StageId(\"{}\")", self.0)
135 }
136}
137
138#[cfg(test)]
139mod tests {
140 use super::*;
141
142 #[test]
143 fn feed_id_display() {
144 let id = FeedId::new(42);
145 assert_eq!(id.to_string(), "feed-42");
146 }
147
148 #[test]
149 fn stage_id_copy() {
150 let a = StageId("detector");
151 let b = a;
152 assert_eq!(a, b);
153 }
154
155 #[test]
156 fn ids_are_copy_and_eq() {
157 let t = TrackId::new(1);
158 let d = DetectionId::new(2);
159 assert_eq!(t, TrackId::new(1));
160 assert_eq!(d, DetectionId::new(2));
161 }
162}