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§
Source§impl ComputedRegistry
impl ComputedRegistry
Sourcepub 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.
Sourcepub 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).
Sourcepub 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.