pub trait ComputePrimitive {
// Required methods
fn manifest(&self) -> &ComputePrimitiveManifest;
fn compute(
&self,
inputs: &HashMap<String, Value>,
parameters: &HashMap<String, Value>,
state: Option<&mut PrimitiveState>,
) -> Result<HashMap<String, Value>, ComputeError>;
}Expand description
A compute primitive that transforms inputs and parameters into outputs.
State must be declared and resettable per manifest validation
(CMP-9, state.allowed => state.resettable); undeclared per-instance
mutability would violate determinism and is detected at runtime by
capture/replay. Structural enforcement on top (derive macros, marker
traits, newtype wrappers) was considered and rejected; see
docs/ledger/decisions/rejected-structural-enforcement-of-statelessness.md.
Required Methods§
fn manifest(&self) -> &ComputePrimitiveManifest
fn compute( &self, inputs: &HashMap<String, Value>, parameters: &HashMap<String, Value>, state: Option<&mut PrimitiveState>, ) -> Result<HashMap<String, Value>, ComputeError>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".