pub struct RateLimit {
pub requests: u32,
pub window: Duration,
pub key: RateKey,
}Expand description
At most requests per window for each key. Bursts up to requests are allowed, then the
allowance refills evenly over the window (token bucket).
ⓘ
App::new("Shop")
.rate_limit(RateLimit::per_ip(300, Duration::from_secs(60)))
.write_limit(RateLimit::per_user(30, Duration::from_secs(60)))Fields§
§requests: u32§window: Duration§key: RateKeyImplementations§
Trait Implementations§
impl Copy for RateLimit
impl StructuralPartialEq for RateLimit
Auto Trait Implementations§
impl Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnsafeUnpin for RateLimit
impl UnwindSafe for RateLimit
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