pub trait Aggregator:
Send
+ Sync
+ Debug {
type Input: Clone;
type Output: Clone;
type Accumulator: Clone + Serialize + for<'de> Deserialize<'de>;
// Required methods
fn new() -> Self
where Self: Sized;
fn update(&mut self, value: Self::Input) -> Result<()>;
fn finalize(&self) -> Result<Self::Output>;
fn accumulator(&self) -> Self::Accumulator;
fn merge(&mut self, other: Self::Accumulator) -> Result<()>;
fn reset(&mut self);
fn count(&self) -> u64;
// Provided methods
fn update_batch(&mut self, values: &[Self::Input]) -> Result<()> { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Core trait for all aggregators
This trait defines the interface for incremental aggregation with support for:
- Incremental updates (feed values one at a time)
- Accumulator merging (for distributed processing)
- State serialization (for persistence and recovery)
Required Associated Types§
Sourcetype Accumulator: Clone + Serialize + for<'de> Deserialize<'de>
type Accumulator: Clone + Serialize + for<'de> Deserialize<'de>
The type of the internal accumulator state (must be serializable)
Required Methods§
Sourcefn accumulator(&self) -> Self::Accumulator
fn accumulator(&self) -> Self::Accumulator
Get the current accumulator state (for serialization/merging)
Sourcefn merge(&mut self, other: Self::Accumulator) -> Result<()>
fn merge(&mut self, other: Self::Accumulator) -> Result<()>
Merge another accumulator into this one (for distributed processing)
Provided Methods§
Sourcefn update_batch(&mut self, values: &[Self::Input]) -> Result<()>
fn update_batch(&mut self, values: &[Self::Input]) -> Result<()>
Update with multiple values at once
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".