1use columnar::Columnar;
4use serde::{Deserialize, Serialize};
5pub use self::operate::Operate;
6pub use self::subgraph::{Subgraph, SubgraphBuilder};
7pub use self::timestamp::{Timestamp, PathSummary};
8pub use self::change_batch::ChangeBatch;
9pub use self::frontier::Antichain;
10
11pub mod change_batch;
12pub mod frontier;
13pub mod timestamp;
14pub mod operate;
15pub mod broadcast;
16pub mod reachability;
17pub mod subgraph;
18
19#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Columnar)]
21pub struct Location {
22 pub node: usize,
24 pub port: Port,
26}
27
28impl Location {
29 pub fn new_target(node: usize, port: usize) -> Location {
31 Location { node, port: Port::Target(port) }
32 }
33 pub fn new_source(node: usize, port: usize) -> Location {
35 Location { node, port: Port::Source(port) }
36 }
37 pub fn is_target(&self) -> bool { matches!(self.port, Port::Target(_)) }
39 pub fn is_source(&self) -> bool { matches!(self.port, Port::Source(_)) }
41}
42
43impl From<Target> for Location {
44 fn from(target: Target) -> Self {
45 Location {
46 node: target.node,
47 port: Port::Target(target.port),
48 }
49 }
50}
51
52impl From<Source> for Location {
53 fn from(source: Source) -> Self {
54 Location {
55 node: source.node,
56 port: Port::Source(source.port),
57 }
58 }
59}
60
61#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Columnar)]
63pub enum Port {
64 Target(usize),
66 Source(usize),
68}
69
70#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
75pub struct Source {
76 pub node: usize,
78 pub port: usize,
80}
81
82impl Source {
83 pub fn new(node: usize, port: usize) -> Self {
85 Self { node, port }
86 }
87}
88
89#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
94pub struct Target {
95 pub node: usize,
97 pub port: usize,
99}
100
101impl Target {
102 pub fn new(node: usize, port: usize) -> Self {
104 Self { node, port }
105 }
106}