pub struct Limiter { /* private fields */ }
Expand description
Rate limiter backed by Redis.
Implementations§
Source§impl Limiter
impl Limiter
Sourcepub fn set_key_prefix(self, key_prefix: &str) -> Self
pub fn set_key_prefix(self, key_prefix: &str) -> Self
Set the key prefix for the limiter’s Redis keys.
Sourcepub fn allow(&self, key: &str, limit: &Limit) -> Result<LimitResult, RedisError>
pub fn allow(&self, key: &str, limit: &Limit) -> Result<LimitResult, RedisError>
Allow a request to be made within the limit.
Sourcepub fn allow_n(
&self,
key: &str,
limit: &Limit,
n: usize,
) -> Result<LimitResult, RedisError>
pub fn allow_n( &self, key: &str, limit: &Limit, n: usize, ) -> Result<LimitResult, RedisError>
Allow n requests to be made within the limit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Limiter
impl RefUnwindSafe for Limiter
impl Send for Limiter
impl Sync for Limiter
impl Unpin for Limiter
impl UnwindSafe for Limiter
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