pub struct RateLimitBuilder { /* private fields */ }Expand description
Builder for RateLimitConfig.
Implementations§
Source§impl RateLimitBuilder
impl RateLimitBuilder
Sourcepub fn per_second(self, secs: u64) -> Self
pub fn per_second(self, secs: u64) -> Self
Shorthand: set the window to the given number of seconds.
Sourcepub fn per_minute(self, minutes: u64) -> Self
pub fn per_minute(self, minutes: u64) -> Self
Shorthand: set the window to the given number of minutes.
Sourcepub fn per_hour(self, hours: u64) -> Self
pub fn per_hour(self, hours: u64) -> Self
Shorthand: set the window to the given number of hours.
Sourcepub fn algorithm(self, algo: RateLimitAlgorithm) -> Self
pub fn algorithm(self, algo: RateLimitAlgorithm) -> Self
Set the rate limiting algorithm.
Sourcepub fn key_extractor(self, extractor: impl KeyExtractor + 'static) -> Self
pub fn key_extractor(self, extractor: impl KeyExtractor + 'static) -> Self
Set the key extractor.
Sourcepub fn include_headers(self, include: bool) -> Self
pub fn include_headers(self, include: bool) -> Self
Whether to include rate limit headers in responses.
Sourcepub fn retry_message(self, msg: impl Into<String>) -> Self
pub fn retry_message(self, msg: impl Into<String>) -> Self
Set the custom message for 429 responses.
Sourcepub fn build(self) -> RateLimitMiddleware
pub fn build(self) -> RateLimitMiddleware
Build the rate limiting middleware.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimitBuilder
impl !RefUnwindSafe for RateLimitBuilder
impl Send for RateLimitBuilder
impl Sync for RateLimitBuilder
impl Unpin for RateLimitBuilder
impl !UnwindSafe for RateLimitBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).