token-bucket 11.1.0

Zero-dependency, lock-free atomic GCRA, Fixed-Window, Token-Bucket, and 64-way sharded bounded keyed rate-limiting engine.
Documentation
use super::*;

/// Formats `RateLimitError` variants as human-readable messages.
impl fmt::Display for RateLimitError {
    /// Writes the error description to the given formatter.
    ///
    /// # Arguments
    ///
    /// - `&Self` - The error variant to format.
    /// - `&mut fmt::Formatter<'_>` - The target formatter.
    ///
    /// # Returns
    ///
    /// - `fmt::Result` - Result of the formatting operation.
    #[inline(always)]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::ZeroRate => f.write_str(ERR_ZERO_RATE),
            Self::ZeroBurst => f.write_str(ERR_ZERO_BURST),
            Self::ZeroPeriod => f.write_str(ERR_ZERO_PERIOD),
            Self::InvalidLimit => f.write_str(ERR_INVALID_LIMIT),
            Self::InvalidCapacity => f.write_str(ERR_INVALID_CAPACITY),
            Self::ZeroCapacity => f.write_str(ERR_ZERO_CAPACITY),
            Self::Overflow => f.write_str(ERR_OVERFLOW),
        }
    }
}

/// Marks `RateLimitError` as a standard error type.
impl Error for RateLimitError {}