#[non_exhaustive]pub struct RateLimit { /* private fields */ }Expand description
One rolling-window request limit.
Implementations§
Source§impl RateLimit
impl RateLimit
Sourcepub fn new(max_requests: usize, window: Duration) -> Result<Self, Error>
pub fn new(max_requests: usize, window: Duration) -> Result<Self, Error>
Creates a non-zero rolling-window request limit.
§Errors
Returns Error::Configuration when max_requests or window is
zero, or when the duration cannot be represented by a monotonic clock.
Sourcepub const fn max_requests(self) -> usize
pub const fn max_requests(self) -> usize
Returns the maximum admitted requests in the rolling 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