pub struct RateLimitingRule {
pub block_duration: NonZeroU64,
pub conditions: Option<RateLimitingRuleConditions>,
pub key: Vec<RateLimitingRuleKeyItem>,
pub limit: NonZeroU64,
pub rank: NonZeroU64,
pub window: RateLimitingRuleWindow,
}
Expand description
A RateLimitingRule defines a rate limiting rule for the project.
JSON schema
{
"description": "A RateLimitingRule defines a rate limiting rule for the project.",
"type": "object",
"required": [
"limit",
"rank"
],
"properties": {
"block_duration": {
"description": "Duration to block the client if rate limit is exceeded (in seconds).",
"default": 60,
"type": "integer",
"minimum": 1.0
},
"conditions": {
"description": "Conditions that must be met for this rule to apply.",
"type": "object",
"properties": {
"continent": {
"description": "Continents that this rule applies to.",
"type": "array",
"items": {
"type": "string",
"enum": [
"AF",
"AN",
"AS",
"EU",
"NA",
"OC",
"SA"
]
}
},
"country": {
"description": "Countries (ISO 3166-1 alpha-2 codes) that this rule applies to.",
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z]{2}$"
}
},
"method": {
"description": "HTTP methods that this rule applies to.",
"type": "array",
"items": {
"type": "string",
"enum": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"TRACE"
]
}
},
"path": {
"description": "Path pattern to match. Can be exact path or regex pattern.",
"type": "string"
},
"regex": {
"description": "Whether the path is a regex pattern.",
"default": false,
"type": "boolean"
}
}
},
"key": {
"description": "Criteria to include in the client key for rate limiting.",
"default": [
"ip"
],
"type": "array",
"items": {
"type": "string",
"enum": [
"ip",
"ua"
]
}
},
"limit": {
"description": "Maximum requests per second within the rate window.",
"type": "integer",
"minimum": 1.0
},
"rank": {
"description": "The rank of the rule. Rules are evaluated in order of rank (lowest first).",
"type": "integer",
"minimum": 1.0
},
"window": {
"description": "Rate window for counting requests.",
"default": "10s",
"type": "string",
"enum": [
"1s",
"10s",
"60s"
]
}
}
}
Fields§
§block_duration: NonZeroU64
Duration to block the client if rate limit is exceeded (in seconds).
conditions: Option<RateLimitingRuleConditions>
§key: Vec<RateLimitingRuleKeyItem>
Criteria to include in the client key for rate limiting.
limit: NonZeroU64
Maximum requests per second within the rate window.
rank: NonZeroU64
The rank of the rule. Rules are evaluated in order of rank (lowest first).
window: RateLimitingRuleWindow
Rate window for counting requests.
Implementations§
Source§impl RateLimitingRule
impl RateLimitingRule
pub fn builder() -> RateLimitingRule
Trait Implementations§
Source§impl Clone for RateLimitingRule
impl Clone for RateLimitingRule
Source§fn clone(&self) -> RateLimitingRule
fn clone(&self) -> RateLimitingRule
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RateLimitingRule
impl Debug for RateLimitingRule
Source§impl<'de> Deserialize<'de> for RateLimitingRule
impl<'de> Deserialize<'de> for RateLimitingRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&RateLimitingRule> for RateLimitingRule
impl From<&RateLimitingRule> for RateLimitingRule
Source§fn from(value: &RateLimitingRule) -> Self
fn from(value: &RateLimitingRule) -> Self
Converts to this type from the input type.
Source§impl From<RateLimitingRule> for RateLimitingRule
impl From<RateLimitingRule> for RateLimitingRule
Source§fn from(value: RateLimitingRule) -> Self
fn from(value: RateLimitingRule) -> Self
Converts to this type from the input type.
Source§impl JsonSchema for RateLimitingRule
impl JsonSchema for RateLimitingRule
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moreSource§impl Serialize for RateLimitingRule
impl Serialize for RateLimitingRule
Source§impl TryFrom<RateLimitingRule> for RateLimitingRule
impl TryFrom<RateLimitingRule> for RateLimitingRule
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§fn try_from(value: RateLimitingRule) -> Result<Self, ConversionError>
fn try_from(value: RateLimitingRule) -> Result<Self, ConversionError>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for RateLimitingRule
impl RefUnwindSafe for RateLimitingRule
impl Send for RateLimitingRule
impl Sync for RateLimitingRule
impl Unpin for RateLimitingRule
impl UnwindSafe for RateLimitingRule
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