downsample 0.0.6

keep downsampled history of data over long period of time
Documentation
#[cfg(feature = "reducers")] pub mod reducers;

/// A reduction function used when a level rolls over into the next level.
///
/// The two input slices contain one logical aggregation window. The window is
/// split only when it wraps around the internal ring buffer.
pub struct Reducer<T> {
    reduce: fn(&[T], &[T]) -> T,
}

impl<T> Clone for Reducer<T> {
    fn clone(&self) -> Self { *self }
}

impl<T> Copy for Reducer<T> {}

impl<T> Reducer<T> {
    pub const fn new(reduce: fn(&[T], &[T]) -> T) -> Self { Self { reduce } }

    pub fn reduce(self, first: &[T], second: &[T]) -> T { (self.reduce)(first, second) }
}