pub struct RateLimiter<B: RateLimitBackend> { /* private fields */ }Expand description
Core rate limiter that delegates to a RateLimitBackend.
Implementations§
Source§impl<B: RateLimitBackend> RateLimiter<B>
impl<B: RateLimitBackend> RateLimiter<B>
Sourcepub fn new(quota: Quota, backend: B) -> Self
pub fn new(quota: Quota, backend: B) -> Self
Create a new rate limiter with the given quota and backend.
Sourcepub async fn check(&self, key: &str) -> RateLimitResult
pub async fn check(&self, key: &str) -> RateLimitResult
Check whether the caller identified by key is allowed to proceed.
Sourcepub fn check_sync(&self, key: &str) -> RateLimitResult
pub fn check_sync(&self, key: &str) -> RateLimitResult
Synchronous version of check.
Blocks the current thread until the check completes. Useful for synchronous frameworks (e.g. Actix, Rocket).
Trait Implementations§
Source§impl<B: Clone + RateLimitBackend> Clone for RateLimiter<B>
impl<B: Clone + RateLimitBackend> Clone for RateLimiter<B>
Source§fn clone(&self) -> RateLimiter<B>
fn clone(&self) -> RateLimiter<B>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<B> Freeze for RateLimiter<B>
impl<B> RefUnwindSafe for RateLimiter<B>where
Arc<B>: RefUnwindSafe,
impl<B> Send for RateLimiter<B>
impl<B> Sync for RateLimiter<B>
impl<B> Unpin for RateLimiter<B>
impl<B> UnsafeUnpin for RateLimiter<B>where
Arc<B>: UnsafeUnpin,
impl<B> UnwindSafe for RateLimiter<B>where
Arc<B>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more