Struct salvo_rate_limiter::RateLimiter
source · pub struct RateLimiter<G, S, I, Q> { /* private fields */ }
Expand description
RateLimiter
is the main struct to used limit user request.
Implementations§
source§impl<G: RateGuard, S: RateStore, I: RateIssuer, P: QuotaGetter<I::Key>> RateLimiter<G, S, I, P>
impl<G: RateGuard, S: RateStore, I: RateIssuer, P: QuotaGetter<I::Key>> RateLimiter<G, S, I, P>
sourcepub fn with_skipper(self, skipper: impl Skipper) -> Self
pub fn with_skipper(self, skipper: impl Skipper) -> Self
Sets skipper and returns new RateLimiter
.
sourcepub fn add_headers(self, add_headers: bool) -> Self
pub fn add_headers(self, add_headers: bool) -> Self
Sets add_headers
and returns new RateLimiter
.
If add_headers
is true, the rate limit headers will be added to the response.
Trait Implementations§
source§impl<G, S, I, P> Handler for RateLimiter<G, S, I, P>where
G: RateGuard<Quota = P::Quota>,
S: RateStore<Key = I::Key, Guard = G>,
P: QuotaGetter<I::Key>,
I: RateIssuer,
impl<G, S, I, P> Handler for RateLimiter<G, S, I, P>where
G: RateGuard<Quota = P::Quota>,
S: RateStore<Key = I::Key, Guard = G>,
P: QuotaGetter<I::Key>,
I: RateIssuer,
source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Handle http request.
Auto Trait Implementations§
impl<G, S, I, Q> Freeze for RateLimiter<G, S, I, Q>
impl<G, S, I, Q> !RefUnwindSafe for RateLimiter<G, S, I, Q>
impl<G, S, I, Q> Send for RateLimiter<G, S, I, Q>
impl<G, S, I, Q> Sync for RateLimiter<G, S, I, Q>
impl<G, S, I, Q> Unpin for RateLimiter<G, S, I, Q>
impl<G, S, I, Q> !UnwindSafe for RateLimiter<G, S, I, Q>
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