logic_mesh/base/link/mod.rs
1// Copyright (c) 2022-2023, Radu Racariu.
2
3//!
4//! Contains link types and traits.
5//!
6
7use uuid::Uuid;
8
9pub mod base;
10pub use base::BaseLink;
11
12/// The current link state
13#[derive(Default, Debug, Clone, Copy, PartialEq)]
14pub enum LinkState {
15 // The link is disconnected
16 #[default]
17 Disconnected,
18 // The link is connected
19 Connected,
20 // The link has an error
21 Error,
22}
23
24///
25/// A link creates a connection from a block
26/// output to another's block input.
27///
28pub trait Link {
29 /// Unique link id
30 fn id(&self) -> &Uuid;
31
32 /// Current link state
33 fn state(&self) -> LinkState;
34
35 /// The id of the target block
36 fn target_block_id(&self) -> &Uuid;
37
38 /// The name of the target input
39 fn target_input(&self) -> &str;
40}