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

pub trait RateLimitState<P, I: Reference>: Default + Send + Sync + Eq + Debug {
    fn last_touched(&self, params: &P) -> Option<I>;

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

Required methods

fn last_touched(&self, params: &P) -> Option<I>

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.

Loading content...

Implementations on Foreign Types

impl RateLimitState<Allower, Always> for ()[src]

Loading content...


impl<P: Reference> RateLimitState<GCRA<P>, P> for ratelimit_meter::algorithms::gcra::State<P>[src]

impl<P: Reference> RateLimitState<LeakyBucket<P>, P> for ratelimit_meter::algorithms::leaky_bucket::State<P>[src]

Loading content...