1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
5pub struct NodeId(pub u32);
6
7impl Display for NodeId {
8 fn fmt(&self, f: &mut Formatter) -> Result {
9 write!(f, "NID({})", self.0)
10 }
11}
12
13#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
15pub struct ServiceId {
16 pub node_id: NodeId,
17 pub local_service_id: LocalServiceId,
18}
19
20impl Display for ServiceId {
21 fn fmt(&self, f: &mut Formatter) -> Result {
22 write!(f, "SID({}:{})", self.node_id.0, self.local_service_id.0)
23 }
24}
25
26#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
28pub struct LocalServiceId(pub u32);
29
30impl LocalServiceId {
31 #[inline]
33 pub fn to_global(self, node_id: NodeId) -> ServiceId {
34 ServiceId {
35 node_id,
36 local_service_id: self,
37 }
38 }
39}
40
41impl Display for LocalServiceId {
42 fn fmt(&self, f: &mut Formatter) -> Result {
43 write!(f, "LID({})", self.0)
44 }
45}