Skip to main content

DeterministicBrick

Trait DeterministicBrick 

Source
pub trait DeterministicBrick: Brick {
    type State: Clone + Default;
    type Input;
    type Output;

    // Required method
    fn execute_pure(
        state: Self::State,
        input: Self::Input,
    ) -> Result<(Self::State, Self::Output), BrickError>;

    // Provided methods
    fn initial_state() -> Self::State { ... }
    fn state_dependencies(&self) -> &[&str] { ... }
}
Expand description

Trait for bricks with deterministic, pure functional execution

Required Associated Types§

Source

type State: Clone + Default

State type (must be cloneable for snapshots)

Source

type Input

Input type

Source

type Output

Output type

Required Methods§

Source

fn execute_pure( state: Self::State, input: Self::Input, ) -> Result<(Self::State, Self::Output), BrickError>

Pure function: (state, input) → (new_state, output)

This function MUST be:

  • Deterministic: same inputs → same outputs
  • Pure: no side effects
  • Total: always returns or errors (no panics)

Provided Methods§

Source

fn initial_state() -> Self::State

Create initial state

Source

fn state_dependencies(&self) -> &[&str]

Get state dependencies for determinism verification

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§