pub trait RateLimiter: Send + Sync {
// Required methods
fn acquire(&self, key: &str) -> Result<RateLimitResult, RateLimitError>;
fn try_acquire(&self, key: &str) -> Result<RateLimitResult, RateLimitError>;
fn reset(&self, key: &str) -> Result<(), RateLimitError>;
}Expand description
RateLimiter trait re-export(限流中间件核心 trait)
Required Methods§
fn acquire(&self, key: &str) -> Result<RateLimitResult, RateLimitError>
fn try_acquire(&self, key: &str) -> Result<RateLimitResult, RateLimitError>
fn reset(&self, key: &str) -> Result<(), RateLimitError>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".