1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use std::{
fmt,
hash::{Hash, Hasher},
sync::Arc
};
pub type ActorId = usize;
pub struct ActorPath(Arc<String>);
impl ActorPath {
pub fn new(path: &str) -> Self {
ActorPath(Arc::new(path.to_string()))
}
}
impl PartialEq for ActorPath {
fn eq(&self, other: &ActorPath) -> bool {
self.0 == other.0
}
}
impl PartialEq<str> for ActorPath {
fn eq(&self, other: &str) -> bool {
self.0 == Arc::new(other.to_string())
}
}
impl Eq for ActorPath { }
impl Hash for ActorPath {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
impl fmt::Display for ActorPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl fmt::Debug for ActorPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl Clone for ActorPath {
fn clone(&self) -> Self {
ActorPath(self.0.clone())
}
}
#[derive(Clone)]
pub struct ActorUri {
pub uid: ActorId,
pub name: Arc<String>,
pub path: ActorPath,
pub host: Arc<String>,
}
impl PartialEq for ActorUri {
fn eq(&self, other: &ActorUri) -> bool {
self.path == other.path
}
}
impl Eq for ActorUri { }
impl Hash for ActorUri {
fn hash<H: Hasher>(&self, state: &mut H) {
self.path.hash(state);
}
}
impl fmt::Display for ActorUri {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.path)
}
}
impl fmt::Debug for ActorUri {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}://{}#{}", self.host, self.path, self.uid)
}
}