protoflow_blocks/
lib.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// This is free and unencumbered software released into the public domain.

#![no_std]
#![deny(unsafe_code)]

#[doc(hidden)]
pub use protoflow_core::prelude;

mod block_config;
pub use block_config::*;

mod block_connections;
pub use block_connections::*;

mod block_instantiation;
pub use block_instantiation::*;

mod block_tag;
pub use block_tag::*;

#[cfg(feature = "std")]
mod stdio;
#[cfg(feature = "std")]
pub use stdio::*;

mod system;
pub use system::*;

pub mod types;
pub use types::*;

pub use protoflow_core::{SystemBuilding, SystemExecution};

include!("blocks/core.rs"); // CoreBlocks
include!("blocks/flow.rs"); // FlowBlocks
include!("blocks/hash.rs"); // HashBlocks
include!("blocks/io.rs"); // IoBlocks
include!("blocks/math.rs"); // MathBlocks
include!("blocks/sys.rs"); // SysBlocks
include!("blocks/text.rs"); // TextBlocks

pub trait AllBlocks:
    CoreBlocks + FlowBlocks + HashBlocks + IoBlocks + MathBlocks + SysBlocks + TextBlocks
{
}

#[cfg(feature = "std")]
#[doc(hidden)]
pub fn build_stdio_system(
    system_name: prelude::String,
    config: StdioConfig,
) -> Result<System, StdioError> {
    use prelude::String;
    Ok(match system_name.as_ref() {
        // CoreBlocks
        "Buffer" => Buffer::<String>::build_system(config)?,
        "Const" => Const::<String>::build_system(config)?,
        "Count" => Count::<String>::build_system(config)?,
        "Delay" => Delay::<String>::build_system(config)?,
        "Drop" => Drop::<String>::build_system(config)?,
        "Random" => Random::<u64>::build_system(config)?,
        // FlowBlocks
        // HashBlocks
        #[cfg(feature = "hash")]
        "Hash" => Hash::build_system(config)?,
        // IoBlocks
        "Decode" => Decode::build_system(config)?,
        "Encode" => Encode::build_system(config)?,
        "EncodeHex" => EncodeHex::build_system(config)?,
        // MathBlocks
        // SysBlocks
        "ReadDir" => ReadDir::build_system(config)?,
        "ReadEnv" => ReadEnv::<String>::build_system(config)?,
        "ReadFile" => ReadFile::build_system(config)?,
        "ReadStdin" => ReadStdin::build_system(config)?,
        "WriteFile" => WriteFile::build_system(config)?,
        "WriteStderr" => WriteStderr::build_system(config)?,
        "WriteStdout" => WriteStdout::build_system(config)?,
        // TextBlocks
        _ => return Err(StdioError::UnknownSystem(system_name))?,
    })
}