pub trait RetractableAccumulator:
Default
+ Clone
+ Send {
type Input;
type Output;
// Required methods
fn add(&mut self, value: Self::Input);
fn retract(&mut self, value: &Self::Input);
fn merge(&mut self, other: &Self);
fn result(&self) -> Self::Output;
fn is_empty(&self) -> bool;
fn reset(&mut self);
// Provided method
fn supports_efficient_retraction(&self) -> bool { ... }
}Expand description
Extension trait for accumulators that support retractions.
Retractable accumulators can “un-apply” a value, which is essential for:
- Late data corrections (emit -old, +new pairs)
- Cascading materialized views
- Changelog-based downstream consumers
§Retraction Efficiency
Some aggregators support O(1) retraction (count, sum, avg), while others
may require O(n) recomputation (min, max without value tracking).
Use supports_efficient_retraction() to check.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn supports_efficient_retraction(&self) -> bool
fn supports_efficient_retraction(&self) -> bool
Returns true if this accumulator can efficiently retract.
Some aggregators (like Min/Max without value tracking) may need to scan all values on retraction if the retracted value was the current min/max.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.