pub struct RateLimiter { /* private fields */ }Expand description
Thread-safe rate limiter
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create a new rate limiter with configuration
Sourcepub async fn check(
&self,
op: OperationType,
ip: Option<&str>,
) -> SecurityResult<()>
pub async fn check( &self, op: OperationType, ip: Option<&str>, ) -> SecurityResult<()>
Sourcepub async fn remaining(&self, op: OperationType, ip: Option<&str>) -> u32
pub async fn remaining(&self, op: OperationType, ip: Option<&str>) -> u32
Get remaining tokens for rate limit headers
Sourcepub async fn limit(&self, op: OperationType) -> u32
pub async fn limit(&self, op: OperationType) -> u32
Get rate limit for operation
Trait Implementations§
Source§impl Clone for RateLimiter
impl Clone for RateLimiter
Source§fn clone(&self) -> RateLimiter
fn clone(&self) -> RateLimiter
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 moreAuto Trait Implementations§
impl Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl !UnwindSafe for RateLimiter
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