[][src]Trait ratelimit_meter::algorithms::RateLimitState

pub trait RateLimitState<P> {
    fn last_touched(&self, params: &P) -> Instant;

Trait that all rate limit states have to implement around housekeeping in keyed rate limiters.

Required Methods

Returns the last time instant that the state had any relevance (i.e. the rate limiter would behave exactly as if it was a new rate limiter after this time).

If the state has not been touched for a given amount of time, the keyed rate limiter will expire it.

Thread safety

This uses a bucket state snapshot to determine eligibility; race conditions can occur.

Implementations on Foreign Types

impl RateLimitState<Allower> for ()


impl RateLimitState<GCRA> for ratelimit_meter::algorithms::gcra::State

impl RateLimitState<LeakyBucket> for ratelimit_meter::algorithms::leaky_bucket::State