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;
10pub use self::stamp::Stamp;
11
12pub mod change_batch;
13pub mod stamp;
14pub mod frontier;
15pub mod timestamp;
16pub mod operate;
17pub mod broadcast;
18pub mod reachability;
19pub mod subgraph;
20
21#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Columnar)]
23pub struct Location {
24 pub node: usize,
26 pub port: Port,
28}
29
30impl Location {
31 pub fn new_target(node: usize, port: usize) -> Location {
33 Location { node, port: Port::Target(port) }
34 }
35 pub fn new_source(node: usize, port: usize) -> Location {
37 Location { node, port: Port::Source(port) }
38 }
39 pub fn is_target(&self) -> bool { matches!(self.port, Port::Target(_)) }
41 pub fn is_source(&self) -> bool { matches!(self.port, Port::Source(_)) }
43}
44
45impl From<Target> for Location {
46 fn from(target: Target) -> Self {
47 Location {
48 node: target.node,
49 port: Port::Target(target.port),
50 }
51 }
52}
53
54impl From<Source> for Location {
55 fn from(source: Source) -> Self {
56 Location {
57 node: source.node,
58 port: Port::Source(source.port),
59 }
60 }
61}
62
63#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Columnar)]
65pub enum Port {
66 Target(usize),
68 Source(usize),
70}
71
72#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
77pub struct Source {
78 pub node: usize,
80 pub port: usize,
82}
83
84impl Source {
85 pub fn new(node: usize, port: usize) -> Self {
87 Self { node, port }
88 }
89}
90
91#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
96pub struct Target {
97 pub node: usize,
99 pub port: usize,
101}
102
103impl Target {
104 pub fn new(node: usize, port: usize) -> Self {
106 Self { node, port }
107 }
108}