pub struct TieredRateLimitConfig {
pub ip: RateLimitConfig,
pub user: RateLimitConfig,
pub api: RateLimitConfig,
pub global: RateLimitConfig,
}Expand description
多层级限流配置
为不同维度(IP、用户、API)配置不同的限流策略。
Fields§
§ip: RateLimitConfigIP 级别配置
user: RateLimitConfig用户级别配置
api: RateLimitConfigAPI 级别配置
global: RateLimitConfig全局配置
Implementations§
Source§impl TieredRateLimitConfig
impl TieredRateLimitConfig
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
校验所有层级配置
Sourcepub fn from_json_str(s: &str) -> Result<Self, ConfigError>
pub fn from_json_str(s: &str) -> Result<Self, ConfigError>
从 JSON 字符串解析
Sourcepub fn to_json_string(&self) -> Result<String, ConfigError>
pub fn to_json_string(&self) -> Result<String, ConfigError>
序列化为 JSON 字符串
Trait Implementations§
Source§impl Clone for TieredRateLimitConfig
impl Clone for TieredRateLimitConfig
Source§fn clone(&self) -> TieredRateLimitConfig
fn clone(&self) -> TieredRateLimitConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 TieredRateLimitConfig
impl Debug for TieredRateLimitConfig
Source§impl Default for TieredRateLimitConfig
impl Default for TieredRateLimitConfig
Source§impl<'de> Deserialize<'de> for TieredRateLimitConfig
impl<'de> Deserialize<'de> for TieredRateLimitConfig
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
Auto Trait Implementations§
impl Freeze for TieredRateLimitConfig
impl RefUnwindSafe for TieredRateLimitConfig
impl Send for TieredRateLimitConfig
impl Sync for TieredRateLimitConfig
impl Unpin for TieredRateLimitConfig
impl UnsafeUnpin for TieredRateLimitConfig
impl UnwindSafe for TieredRateLimitConfig
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