1use std::{fmt, sync::Arc};
3
4macro_rules! numeric_id {
5 ($name:ident) => {
6 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
7 pub struct $name(u64);
8
9 impl $name {
10 pub const fn new(value: u64) -> Self {
11 Self(value)
12 }
13 pub const fn get(self) -> u64 {
14 self.0
15 }
16 }
17
18 impl fmt::Display for $name {
19 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
20 self.0.fmt(formatter)
21 }
22 }
23 };
24}
25
26numeric_id!(SessionId);
27numeric_id!(TaskId);
28numeric_id!(StreamEpoch);
29
30#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub struct MountId(Arc<str>);
32
33impl MountId {
34 pub fn new(path: impl Into<Arc<str>>) -> Self {
35 Self(path.into())
36 }
37 pub fn as_str(&self) -> &str {
38 &self.0
39 }
40}
41
42impl std::borrow::Borrow<str> for MountId {
43 fn borrow(&self) -> &str {
46 &self.0
47 }
48}
49
50impl fmt::Display for MountId {
51 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
52 self.0.fmt(formatter)
53 }
54}
55
56impl From<Arc<str>> for MountId {
57 fn from(value: Arc<str>) -> Self {
58 Self(value)
59 }
60}
61
62impl From<&str> for MountId {
63 fn from(value: &str) -> Self {
64 Self(Arc::from(value))
65 }
66}