scepter 0.1.5

Composable primitives for planet-scale time-series routing, indexing, and aggregation.
Documentation
use std::convert::Infallible;
use std::error::Error;
use std::fmt;

/// Errors produced by time-bucketed collection aggregation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CollectionError<ReducerError = Infallible> {
    /// Bucket period was zero.
    EmptyBucketPeriod,
    /// Bucket offset was greater than or equal to the bucket period.
    OffsetOutsidePeriod,
    /// Delta point was older than the configured admission window.
    LateDelta,
    /// Reducer failed while combining two deltas.
    Reducer(ReducerError),
}

impl<ReducerError: fmt::Display> fmt::Display for CollectionError<ReducerError> {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::EmptyBucketPeriod => {
                formatter.write_str("bucket period must be greater than zero")
            }
            Self::OffsetOutsidePeriod => {
                formatter.write_str("bucket offset must be less than the bucket period")
            }
            Self::LateDelta => formatter.write_str("delta point is outside the admission window"),
            Self::Reducer(error) => write!(formatter, "collection reducer failed: {error}"),
        }
    }
}

impl<ReducerError> Error for CollectionError<ReducerError> where ReducerError: Error + 'static {}