1use serde::{Deserialize, Serialize};
2
3use crate::PortId;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub struct EdgeId(pub u64);
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Edge {
10 pub id: EdgeId,
11 pub source_port: PortId,
12
13 pub target_port: PortId,
14}
15
16impl Edge {
17 pub fn new(id: EdgeId) -> Self {
18 Self {
19 id,
20 source_port: PortId(0),
21 target_port: PortId(0),
22 }
23 }
24 pub fn source(mut self, port: PortId) -> Self {
25 self.source_port = port;
26 self
27 }
28 pub fn target(mut self, port: PortId) -> Self {
29 self.target_port = port;
30 self
31 }
32}