1use std::collections::HashSet;
2
3use crate::prelude::*;
4
5pub struct DataflowLayout {
6 pub inputs: HashSet<InputID>,
7 pub outputs: HashSet<OutputID>,
8}
9
10impl Default for DataflowLayout {
11 fn default() -> Self {
12 Self::new()
13 }
14}
15
16impl DataflowLayout {
17 pub fn new() -> Self {
18 Self {
19 inputs: HashSet::new(),
20 outputs: HashSet::new(),
21 }
22 }
23
24 pub async fn create_node<T>(&mut self, node: impl AsyncFn(&mut NodeIO) -> T) -> (NodeID, T) {
25 let mut io = NodeIO::new();
26 let result = node(&mut io).await;
27
28 self.inputs.extend(io.inputs);
29 self.outputs.extend(io.outputs);
30
31 (io.id, result)
32 }
33}