pub enum RateLimitRule {
Inherit,
Off,
Limit {
requests: u32,
window_secs: u64,
},
}Expand description
How many requests one client may make in a window before an endpoint starts
answering 429.
Written as "<requests>/<window>" — "100/1m", "5/30s", "1000/1h", or
the bare-seconds form "100/60". Two words stand in for a number:
"off" lifts the limit whatever the level above set, and "inherit" (the
default, and what an omitted key means) defers to it.
The levels, narrowest last: [rate_limit] default in main.toml, a
resource’s [rate_limit] all, and finally the per-action key. So a global
"100/1m" with create = "5/1m" on one resource limits everything to a
hundred a minute except that one endpoint, which takes five.
Variants§
Inherit
Nothing said here; the level above decides.
Off
No limit, whatever the level above says.
Limit
requests per window_secs, per client address.
Implementations§
Source§impl RateLimitRule
impl RateLimitRule
Sourcepub fn parse(s: &str) -> Option<RateLimitRule>
pub fn parse(s: &str) -> Option<RateLimitRule>
Parse the string form. None is a spelling that means nothing — the
caller turns it into a load error naming the file it came from, rather
than a limit nobody asked for or, worse, a silently missing one.
Sourcepub fn or(self, fallback: RateLimitRule) -> RateLimitRule
pub fn or(self, fallback: RateLimitRule) -> RateLimitRule
This rule if it says anything, else fallback.
Trait Implementations§
Source§impl Clone for RateLimitRule
impl Clone for RateLimitRule
Source§fn clone(&self) -> RateLimitRule
fn clone(&self) -> RateLimitRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RateLimitRule
Source§impl Debug for RateLimitRule
impl Debug for RateLimitRule
Source§impl Default for RateLimitRule
impl Default for RateLimitRule
Source§fn default() -> RateLimitRule
fn default() -> RateLimitRule
Source§impl<'de> Deserialize<'de> for RateLimitRule
impl<'de> Deserialize<'de> for RateLimitRule
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
impl Eq for RateLimitRule
Source§impl PartialEq for RateLimitRule
impl PartialEq for RateLimitRule
impl StructuralPartialEq for RateLimitRule
Auto Trait Implementations§
impl Freeze for RateLimitRule
impl RefUnwindSafe for RateLimitRule
impl Send for RateLimitRule
impl Sync for RateLimitRule
impl Unpin for RateLimitRule
impl UnsafeUnpin for RateLimitRule
impl UnwindSafe for RateLimitRule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.