pub trait RateLimitBackend:
Send
+ Sync
+ 'static {
// Required method
fn check(
&self,
key: &str,
quota: &Quota,
) -> impl Future<Output = RateLimitResult> + Send;
}Expand description
Backend trait for rate limit state storage.
Uses native async fn in trait (MSRV 1.85) instead of
#[async_trait], so a check dispatches no future boxing and no
vtable call. The returned future is required to be Send so
backends work on multi-threaded runtimes (the Tower layer’s boxed
future, spawned tasks).
The trait is intentionally not dyn-compatible: every consumer in
this crate is generic over B: RateLimitBackend, keeping the hot
path statically dispatched. If you need heterogeneous backend sets,
wrap them in your own enum rather than a dyn trait object.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl RateLimitBackend for InMemoryBackend
Available on crate feature
in-memory only.impl RateLimitBackend for NoopBackend
Available on crate feature
test-util only.impl RateLimitBackend for RedisBackend
Available on crate feature
redis only.impl RateLimitBackend for SlidingWindowBackend
Available on crate feature
sliding-window only.impl RateLimitBackend for SqliteBackend
Available on crate feature
sqlite only.