1use serde::{Deserialize, Serialize};
4
5use crate::NodeName;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
16pub enum EdgeKind {
17 Exec,
18 Data,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
23pub struct PinRef {
24 pub(crate) node: NodeName,
25 pub(crate) pin: String,
26}
27
28impl PinRef {
29 pub fn new(node: NodeName, pin: impl Into<String>) -> Self {
30 Self {
31 node,
32 pin: pin.into(),
33 }
34 }
35
36 pub fn node(&self) -> &str {
37 self.node.as_str()
38 }
39
40 pub fn pin(&self) -> &str {
41 &self.pin
42 }
43}
44
45#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
47pub struct Edge {
48 pub(crate) kind: EdgeKind,
49 from: PinRef,
50 to: PinRef,
51}
52
53impl Edge {
54 pub fn new(kind: EdgeKind, from: PinRef, to: PinRef) -> Self {
55 Self { kind, from, to }
56 }
57
58 pub fn kind(&self) -> EdgeKind {
59 self.kind
60 }
61
62 pub fn from(&self) -> &PinRef {
63 &self.from
64 }
65
66 pub fn to(&self) -> &PinRef {
67 &self.to
68 }
69}