pub struct RateLimit {
pub max_requests: u32,
pub window: Duration,
}Expand description
How many requests a single client may make per window.
Fields§
§max_requests: u32The maximum number of requests permitted within one window.
window: DurationThe length of the fixed window.
Implementations§
Source§impl RateLimit
impl RateLimit
Sourcepub const DEFAULT_MAX_REQUESTS: u32 = 300
pub const DEFAULT_MAX_REQUESTS: u32 = 300
A generous default for a general-purpose JSON API: 300 requests per minute per client. High enough not to trip a normal UI, low enough to blunt a single abusive caller; a deployment tunes it from config.
Sourcepub const DEFAULT_WINDOW: Duration
pub const DEFAULT_WINDOW: Duration
The default window length (60 seconds).
Trait Implementations§
impl Copy for RateLimit
impl Eq for RateLimit
impl StructuralPartialEq for RateLimit
Auto Trait Implementations§
impl Forget for RateLimit
impl Freeze for RateLimit
impl Move 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