Skip to main content

Reducer

Trait Reducer 

Source
pub trait Reducer<T>:
    Send
    + Sync
    + 'static {
    // Required method
    fn reduce(&self, current: T, update: T) -> T;
}
Expand description

Combines a current value and an incoming update into the next value.

Implementors must be deterministic — the merge function runs inside CompiledGraph::execute_loop and a reducer that depends on outside state (random RNG, wall-clock time, …) breaks crash-resume reproducibility.

Required Methods§

Source

fn reduce(&self, current: T, update: T) -> T

Combine current and update. Implementations are free to consume both; many simply return update (replace) or push the second into the first (append).

Implementors§

Source§

impl<K, V> Reducer<HashMap<K, V>> for MergeMap<K, V>
where K: Eq + Hash + Send + Sync + 'static, V: Send + Sync + 'static,

Source§

impl<T> Reducer<T> for Max<T>
where T: Ord + Send + Sync + 'static,

Source§

impl<T> Reducer<T> for Replace
where T: Send + Sync + 'static,

Source§

impl<U> Reducer<Vec<U>> for Append<U>
where U: Send + Sync + 'static,