Struct ComputedRegistry
pub struct ComputedRegistry { /* private fields */ }Expand description
Registry of computed variables with dependency-ordered evaluation.
Variables are kept in topological order: if var A depends on var B, then B appears before A in the internal list. This invariant is maintained at registration time using Kahn’s algorithm.
Implementations§
§impl ComputedRegistry
impl ComputedRegistry
pub fn new() -> ComputedRegistry
pub fn new() -> ComputedRegistry
Create an empty registry.
pub fn register(&mut self, var: ComputedVar)
pub fn register(&mut self, var: ComputedVar)
Register a computed variable. Re-sorts the internal list and rebuilds the dependency index. Panics if the new variable introduces a cycle.
pub fn recompute(&self, state: &State) -> Vec<String>
pub fn recompute(&self, state: &State) -> Vec<String>
Recompute all variables in dependency order. Returns the keys whose derived values actually changed (old != new).
pub fn recompute_affected(
&self,
state: &State,
changed_keys: &[String],
) -> Vec<String>
pub fn recompute_affected( &self, state: &State, changed_keys: &[String], ) -> Vec<String>
Recompute only the variables affected by the given changed keys. Uses the dependency index for O(1) lookup of affected variables, then evaluates them in topological order. Transitively propagates: if a computed var changes, its dependents are also scheduled for recomputation. Returns keys that actually changed.
pub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the dependency graph. Returns Ok(()) if there are no cycles,
or Err(message) describing the problem.
pub fn describe(&self) -> Vec<ComputedContract>
pub fn describe(&self) -> Vec<ComputedContract>
Return serializable contract metadata for all computed variables.