pictorus_blocks/lib.rs
1//! This crate contains all of the blocks available in the Pictorus UI.
2//! These blocks are implemented using the traits defined in the `pictorus-traits`
3//! crate.
4//!
5//! ## Block Types
6//! There are currently two categories of blocks defined in this crate:
7//! - Core Blocks - These are blocks that are available on all platforms.
8//! - Standard Blocks - These blocks are only available on platforms that support the standard library.
9//!
10//! ## Implementing Custom Blocks
11//! The blocks in this crate can be helpful as a starting point for implementing a custom block,
12//! but are likely to be much more complex than required for a typical use case.
13//! The blocks in this crate typically support a wide variety of input/output types,
14//! and as such, need to use more complex patterns like macros and recursive traits to cover all possible cases.
15//! If you are implementing a custom block for a specific case, you can likely create a much simpler implementation
16//! by restricting the input/output types you need to support. We will be adding more examples of simple custom blocks in the future.
17#![no_std]
18use pictorus_block_data::BlockData;
19
20#[cfg(any(feature = "std", test))]
21extern crate std;
22
23// TODO: Remoove this when we no longer require alloc
24extern crate alloc;
25
26// Set of blocks that do not depend on `std` or `alloc`
27mod core_blocks;
28pub use core_blocks::*;
29
30// Set of blocks that depend on `std`
31#[cfg(feature = "std")]
32mod std_blocks;
33#[cfg(feature = "std")]
34pub use std_blocks::*;
35
36pub mod byte_data;
37mod nalgebra_interop;
38mod stale_tracker;
39pub(crate) mod traits;
40pub use traits::Scalar;
41
42#[cfg(any(test, doctest))]
43mod testing;
44
45#[derive(Debug)]
46/// Error raised when parsing an enum from a string fails.
47pub struct ParseEnumError;
48
49/// Trait for blocks that can have stale/invalid ouput.
50///
51/// Blocks that implement this trait should output a false value for `is_valid`
52/// if the output is not in a valid state.
53pub trait IsValid {
54 // This still uses the deprecated BlockData type.
55 // Eventually we will need to update/replace this trait when BlockData is removed.
56 fn is_valid(&self, app_time_s: f64) -> BlockData;
57}