use serde::{Deserialize, Serialize};
use crate::NodeName;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum EdgeKind {
Exec,
Data,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct PinRef {
pub(crate) node: NodeName,
pub(crate) pin: String,
}
impl PinRef {
pub fn new(node: NodeName, pin: impl Into<String>) -> Self {
Self {
node,
pin: pin.into(),
}
}
pub fn node(&self) -> &str {
self.node.as_str()
}
pub fn pin(&self) -> &str {
&self.pin
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Edge {
pub(crate) kind: EdgeKind,
from: PinRef,
to: PinRef,
}
impl Edge {
pub fn new(kind: EdgeKind, from: PinRef, to: PinRef) -> Self {
Self { kind, from, to }
}
pub fn kind(&self) -> EdgeKind {
self.kind
}
pub fn from(&self) -> &PinRef {
&self.from
}
pub fn to(&self) -> &PinRef {
&self.to
}
}