use columnar::Columnar;
use serde::{Deserialize, Serialize};
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, Serialize, Deserialize, Columnar)]
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 { matches!(self.port, Port::Target(_)) }
pub fn is_source(&self) -> bool { matches!(self.port, Port::Source(_)) }
}
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, Serialize, Deserialize, Columnar)]
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 }
}
}