Skip to main content

TokenBucketInstant

Trait TokenBucketInstant 

Source
pub(crate) trait TokenBucketInstant:
    Copy
    + Clone
    + Debug
    + PartialEq
    + Eq
    + PartialOrd
    + Ord {
    const IGNORE_THRESHOLD: Duration;

    // Required methods
    fn checked_add(&self, duration: Duration) -> Option<Self>;
    fn checked_duration_since(&self, earlier: Self) -> Option<Duration>;

    // Provided method
    fn saturating_duration_since(&self, earlier: Self) -> Duration { ... }
}
Expand description

Any type implementing this must be represented as a measurement of a monotonically nondecreasing clock.

Required Associated Constants§

Source

const IGNORE_THRESHOLD: Duration

An unrealistically large time jump.

We assume that any time change larger than this indicates a broken monotonic clock, and the bucket will not be refilled.

Required Methods§

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TokenBucketInstant for Instant

Source§

const IGNORE_THRESHOLD: Duration

Source§

fn checked_add(&self, duration: Duration) -> Option<Self>

Source§

fn checked_duration_since(&self, earlier: Self) -> Option<Duration>

Source§

fn saturating_duration_since(&self, earlier: Self) -> Duration

Implementors§