pub trait RateLimitStore {
// Required methods
fn check(
&self,
key: &RateLimitKey,
policy: &RateLimitPolicy,
) -> impl Future<Output = Result<RateLimitOutcome, StoreError>>;
fn record_failure(
&self,
key: &RateLimitKey,
policy: &RateLimitPolicy,
) -> impl Future<Output = Result<(), StoreError>>;
fn clear_failures(
&self,
key: &RateLimitKey,
) -> impl Future<Output = Result<(), StoreError>>;
}Expand description
Rate-limit storage (RFC-008 §4).
Implementations record failure counts within a rolling window keyed by
RateLimitKey. All methods are infallible from the caller’s perspective;
backend errors are handled per RateLimitUnavailable.
Required Methods§
Sourcefn check(
&self,
key: &RateLimitKey,
policy: &RateLimitPolicy,
) -> impl Future<Output = Result<RateLimitOutcome, StoreError>>
fn check( &self, key: &RateLimitKey, policy: &RateLimitPolicy, ) -> impl Future<Output = Result<RateLimitOutcome, StoreError>>
Check whether the key is within the policy limit before an operation. Does not mutate state.
Sourcefn record_failure(
&self,
key: &RateLimitKey,
policy: &RateLimitPolicy,
) -> impl Future<Output = Result<(), StoreError>>
fn record_failure( &self, key: &RateLimitKey, policy: &RateLimitPolicy, ) -> impl Future<Output = Result<(), StoreError>>
Record a failure for the given key within the current window.
Sourcefn clear_failures(
&self,
key: &RateLimitKey,
) -> impl Future<Output = Result<(), StoreError>>
fn clear_failures( &self, key: &RateLimitKey, ) -> impl Future<Output = Result<(), StoreError>>
Clear all failure counters for the given key (called after a successful redemption so legitimate users are not locked out).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".