pub struct RateLimit { /* private fields */ }Expand description
A request allowance: limit requests per window.
limit is a NonZeroU32 so that a misconfiguration which means “refuse
everything” is not expressible by accident. The type has no “unlimited”
state either: a caller that genuinely wants no limit should not put this
type in the path at all, so “unlimited” can never be the accidental result
of a zero that survived a round trip through configuration.
Implementations§
Source§impl RateLimit
impl RateLimit
Sourcepub const fn new(limit: NonZeroU32, window: Duration) -> Self
pub const fn new(limit: NonZeroU32, window: Duration) -> Self
An allowance of limit requests per window.
§Panics
If window is zero. A window of zero is a server that refuses
everything, and that is not a condition worth discovering from traffic,
so it is rejected at construction. limit cannot be zero by type.
Sourcepub const fn limit(&self) -> NonZeroU32
pub const fn limit(&self) -> NonZeroU32
Requests permitted per window.
Trait Implementations§
impl Copy for RateLimit
impl Eq 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