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
92
93
94
95
96
97
98
99
100
101
102
103
104
pub use self::operate::Operate;
pub use self::subgraph::{Subgraph, SubgraphBuilder};
pub use self::timestamp::{Timestamp, PathSummary};
pub use self::change_batch::ChangeBatch;
pub use self::frontier::Antichain;
pub mod change_batch;
pub mod frontier;
pub mod timestamp;
pub mod operate;
pub mod broadcast;
pub mod reachability;
pub mod subgraph;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Abomonation, Serialize, Deserialize)]
pub struct Location {
pub node: usize,
pub port: Port,
}
impl Location {
pub fn new_target(node: usize, port: usize) -> Location {
Location { node, port: Port::Target(port) }
}
pub fn new_source(node: usize, port: usize) -> Location {
Location { node, port: Port::Source(port) }
}
pub fn is_target(&self) -> bool { if let Port::Target(_) = self.port { true } else { false } }
pub fn is_source(&self) -> bool { if let Port::Source(_) = self.port { true } else { false } }
}
impl From<Target> for Location {
fn from(target: Target) -> Self {
Location {
node: target.node,
port: Port::Target(target.port),
}
}
}
impl From<Source> for Location {
fn from(source: Source) -> Self {
Location {
node: source.node,
port: Port::Source(source.port),
}
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Abomonation, Serialize, Deserialize)]
pub enum Port {
Target(usize),
Source(usize),
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub struct Source {
pub node: usize,
pub port: usize,
}
impl Source {
pub fn new(node: usize, port: usize) -> Self {
Self { node, port }
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub struct Target {
pub node: usize,
pub port: usize,
}
impl Target {
pub fn new(node: usize, port: usize) -> Self {
Self { node, port }
}
}