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
- The processor receives a well-formed Quad (Root, Pointer=sentinel, Tree).
- The processor produces a well-formed Quad (Root, Pointer, Tree).
- The output Pointer becomes the key that the boundary strips before delivery to the successor. The processor has no control over what happens after.
- 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§
Provided Methods§
Sourcefn process_layer(
&mut self,
unit_id: UnitId,
cycle_index: u64,
target_layer: Layer,
server_output: &Quad,
) -> Result<Quad, UnitProcessorError>
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.
Sourcefn externalize_state(&self, _unit_id: UnitId) -> Option<Quad>
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".