logic_mesh/base/link/
base.rs1use uuid::Uuid;
8
9use super::{Link, LinkState};
10
11#[derive(Debug, Default, Clone, PartialEq)]
19pub struct BaseLink<Tx> {
20 pub id: Uuid,
22 pub target_block_id: Uuid,
24 pub target_input: String,
26 pub tx: Option<Tx>,
28 pub state: LinkState,
30}
31
32impl<Tx: Clone> Link for BaseLink<Tx> {
33 fn id(&self) -> &Uuid {
34 &self.id
35 }
36
37 fn target_block_id(&self) -> &Uuid {
38 &self.target_block_id
39 }
40
41 fn target_input(&self) -> &str {
42 &self.target_input
43 }
44
45 fn state(&self) -> LinkState {
46 self.state
47 }
48}
49
50impl<Tx> BaseLink<Tx> {
51 pub fn new(target_block_id: Uuid, target_input: String) -> Self {
52 Self {
53 id: Uuid::new_v4(),
54 target_block_id,
55 target_input,
56 tx: None,
57 state: LinkState::Disconnected,
58 }
59 }
60}