pub struct MultiRateLimiter { /* private fields */ }Expand description
Multi-dimensional rate limiting strategy
Applies multiple limiters to the same request; rejects if any limiter rejects. Suitable for scenarios that simultaneously restrict at both the IP level and the user level.
Implementations§
Source§impl MultiRateLimiter
impl MultiRateLimiter
Sourcepub fn new(limiters: Vec<Arc<dyn RateLimiter>>) -> Self
pub fn new(limiters: Vec<Arc<dyn RateLimiter>>) -> Self
Creates a multi-dimensional rate limiter
Sourcepub fn with_limiter(self, limiter: Arc<dyn RateLimiter>) -> Self
pub fn with_limiter(self, limiter: Arc<dyn RateLimiter>) -> Self
Adds a rate limiter
pub fn limiter_count(&self) -> usize
Sourcepub fn check_all(&self, key: &str) -> Result<RateLimitResult, RateLimitError>
pub fn check_all(&self, key: &str) -> Result<RateLimitResult, RateLimitError>
Checks all limiters and returns the strictest result
If any limiter rejects, returns a rejected result (with the fewest remaining). If all allow, returns the result with the fewest remaining.
Auto Trait Implementations§
impl !RefUnwindSafe for MultiRateLimiter
impl !UnwindSafe for MultiRateLimiter
impl Freeze for MultiRateLimiter
impl Send for MultiRateLimiter
impl Sync for MultiRateLimiter
impl Unpin for MultiRateLimiter
impl UnsafeUnpin for MultiRateLimiter
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