Skip to main content

UnitProcessor

Trait UnitProcessor 

Source
pub trait UnitProcessor: Send + 'static {
    // Required methods
    fn process(
        &mut self,
        unit_id: UnitId,
        cycle_index: u64,
        input: &Quad,
        data: &Quad,
    ) -> Result<Quad, UnitProcessorError>;
    fn name(&self) -> &str;

    // Provided methods
    fn process_layer(
        &mut self,
        unit_id: UnitId,
        cycle_index: u64,
        target_layer: Layer,
        server_output: &Quad,
    ) -> Result<Quad, UnitProcessorError> { ... }
    fn externalize_state(&self, _unit_id: UnitId) -> Option<Quad> { ... }
}
Expand description

The trait that any unit implementation must satisfy.

This is the protocol boundary contract from the processing side. The input Quad has its external key ALREADY STRIPPED by the boundary. The processor never sees the predecessor’s Pointer.

§Contract

  1. The processor receives a well-formed Quad (Root, Pointer=sentinel, Tree).
  2. The processor produces a well-formed Quad (Root, Pointer, Tree).
  3. The output Pointer becomes the key that the boundary strips before delivery to the successor. The processor has no control over what happens after.
  4. The processor MUST NOT attempt to reconstruct the stripped Pointer. There is no mechanism to do so within the type system.

§Lifecycle

  • process() is called once per ring cycle for this unit (Server layer).
  • process_layer() is called for horizontal presentation processing (Client, Interface layers).
  • The processor may maintain internal state across cycles.
  • Genesis processing uses the same interface; the input will be the seed-derived Quad (for FU) or the predecessor’s genesis output.

Required Methods§

Source

fn process( &mut self, unit_id: UnitId, cycle_index: u64, input: &Quad, data: &Quad, ) -> Result<Quad, UnitProcessorError>

Process an incoming (stripped) Quad and produce an output Quad.

This is the Server-layer processing path (vertical ring backbone).

Source

fn name(&self) -> &str

Human-readable name for this processor implementation.

Provided Methods§

Source

fn process_layer( &mut self, unit_id: UnitId, cycle_index: u64, target_layer: Layer, server_output: &Quad, ) -> Result<Quad, UnitProcessorError>

Process a Quad for a specific SOM layer (horizontal presentation path).

§Default implementation

The default creates a deterministic transform based on unit ID, cycle, and target layer. Processors that need custom layer behavior override this.

Source

fn externalize_state(&self, _unit_id: UnitId) -> Option<Quad>

Externalize accumulated processor state for Data layer deposit.

Default: None — no state to externalize (backward compatible).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§