pub struct RateLimiter {
pub prefix: String,
pub rules: BTreeMap<Duration, u64>,
}Fields§
§prefix: String§rules: BTreeMap<Duration, u64>Implementations§
Source§impl RateLimiter
impl RateLimiter
pub fn new<I: Into<String>>(prefix: I) -> Self
pub fn add_limit(&mut self, duration: Duration, amount: u64)
pub fn check_stamp<D: Into<Datetime>>( &self, stamp: &Stamp, now: D, ) -> (Permit, Option<Duration>)
pub async fn check_kv<D: Into<Datetime>>( &self, kv: &KvStore, ip_addr: &str, now: D, ) -> Result<Permit>
Auto Trait Implementations§
impl Freeze for RateLimiter
impl RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin 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