[][src]Struct http_desync_guardian::ultralight_rate_limiter::UltraLightRateLimiter

pub struct UltraLightRateLimiter { /* fields omitted */ }

An ultra light rate limiter. It allows exactly limit queries per slot of time (without handling bursts), which makes it much simpler to test, and it's good enough (to limit logging).

Implementations

impl UltraLightRateLimiter[src]

pub fn new(limit_per_second: f64, ticker_ms: fn() -> u64) -> Self[src]

Creates a new rate limiter based on the desired limit per second, and a clock function.

Arguments

limit_per_second how many permits it issues per second. If greater than 1, then it's truncated ticker_ms a clock function with ms precision. E.g. a MONOTONIC_CLOCK

pub fn try_acquire_value<T>(&self, value: T) -> Option<T>[src]

pub fn try_acquire(&self) -> bool[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.