pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter middleware.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(config: RateLimitConfig) -> RateLimiter
pub fn new(config: RateLimitConfig) -> RateLimiter
Create a new rate limiter with the given configuration.
Sourcepub fn for_login() -> RateLimiter
pub fn for_login() -> RateLimiter
Create a rate limiter for login endpoints (strict).
Sourcepub fn for_api() -> RateLimiter
pub fn for_api() -> RateLimiter
Create a rate limiter for API endpoints (lenient).
Sourcepub fn state(&self) -> &RateLimiterState
pub fn state(&self) -> &RateLimiterState
Get the underlying state for manual operations.
Trait Implementations§
Source§impl Clone for RateLimiter
impl Clone for RateLimiter
Source§fn clone(&self) -> RateLimiter
fn clone(&self) -> RateLimiter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S, B> Transform<S, ServiceRequest> for RateLimiterwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
B: 'static,
impl<S, B> Transform<S, ServiceRequest> for RateLimiterwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
B: 'static,
Source§type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
Source§type Transform = RateLimiterMiddleware<S>
type Transform = RateLimiterMiddleware<S>
The
TransformService value created by this factorySource§type Future = Ready<Result<<RateLimiter as Transform<S, ServiceRequest>>::Transform, <RateLimiter as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<RateLimiter as Transform<S, ServiceRequest>>::Transform, <RateLimiter as Transform<S, ServiceRequest>>::InitError>>
The future response value.
Source§fn new_transform(
&self,
service: S,
) -> <RateLimiter as Transform<S, ServiceRequest>>::Future
fn new_transform( &self, service: S, ) -> <RateLimiter as Transform<S, ServiceRequest>>::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations§
impl Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl !UnwindSafe for RateLimiter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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