1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2022-2023, Radu Racariu.

use uuid::Uuid;

pub mod base;
pub use base::BaseLink;

#[derive(Default, Debug, Clone, Copy, PartialEq)]
pub enum LinkState {
    #[default]
    Disconnected,
    Connected,
    Error,
}

///
/// A link creates a connection from a block
/// output to another's block input.
///
pub trait Link {
    /// Unique link id
    fn id(&self) -> &Uuid;

    /// Current link state
    fn state(&self) -> LinkState;

    /// The id of the target block
    fn target_block_id(&self) -> &Uuid;

    /// The name of the target input
    fn target_input(&self) -> &str;
}