protoflow_core/
block_descriptor.rs

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
// This is free and unencumbered software released into the public domain.

use crate::{
    prelude::{vec, MaybeLabeled, MaybeNamed, Vec},
    ParameterDescriptor, PortDescriptor,
};

/// A block is an autonomous unit of computation in a system.
pub trait BlockDescriptor: MaybeNamed + MaybeLabeled {
    /// A description of this block's I/O ports.
    fn ports(&self) -> Vec<PortDescriptor> {
        let mut result = self.inputs();
        result.append(&mut self.outputs());
        result
    }

    /// A description of this block's input ports.
    fn inputs(&self) -> Vec<PortDescriptor> {
        vec![]
    }

    /// A description of this block's output ports.
    fn outputs(&self) -> Vec<PortDescriptor> {
        vec![]
    }

    /// A description of this block's parameters.
    fn parameters(&self) -> Vec<ParameterDescriptor> {
        vec![]
    }
}