1use core::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub struct SessionId(pub u64);
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
11pub struct ModelId(pub u64);
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct ModelVersion {
16 pub major: u16,
17 pub minor: u16,
18 pub patch: u16,
19}
20
21impl ModelVersion {
22 pub const fn new(major: u16, minor: u16, patch: u16) -> Self {
23 Self {
24 major,
25 minor,
26 patch,
27 }
28 }
29}
30
31impl fmt::Display for SessionId {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "session#{}", self.0)
34 }
35}
36
37impl fmt::Display for ModelId {
38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39 write!(f, "model#{}", self.0)
40 }
41}
42
43impl fmt::Display for ModelVersion {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn version_orders_and_displays() {
55 assert!(ModelVersion::new(1, 2, 0) > ModelVersion::new(1, 1, 9));
56 assert_eq!(ModelVersion::new(0, 1, 0).to_string(), "0.1.0");
57 assert_eq!(SessionId(7).to_string(), "session#7");
58 }
59}