pub struct StandardRateLimiter { /* private fields */ }Expand description
Standard rate limiter using token bucket
Implementations§
Trait Implementations§
Source§impl RateLimiter for StandardRateLimiter
impl RateLimiter for StandardRateLimiter
Source§fn check_rate_limit<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 RateLimitKey,
) -> Pin<Box<dyn Future<Output = Result<RateLimitDecision>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check_rate_limit<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 RateLimitKey,
) -> Pin<Box<dyn Future<Output = Result<RateLimitDecision>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if request is allowed
Source§fn record_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 RateLimitKey,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn record_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 RateLimitKey,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Record request for rate limiting
Source§fn apply_penalty<'life0, 'life1, 'async_trait>(
&'life0 self,
client_id: &'life1 str,
factor: f32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn apply_penalty<'life0, 'life1, 'async_trait>(
&'life0 self,
client_id: &'life1 str,
factor: f32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply penalty for threats
Source§fn get_stats(&self) -> RateLimiterStats
fn get_stats(&self) -> RateLimiterStats
Get rate limit stats
Auto Trait Implementations§
impl !Freeze for StandardRateLimiter
impl !RefUnwindSafe for StandardRateLimiter
impl !UnwindSafe for StandardRateLimiter
impl Send for StandardRateLimiter
impl Sync for StandardRateLimiter
impl Unpin for StandardRateLimiter
impl UnsafeUnpin for StandardRateLimiter
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more