[][src]Struct tide_governor::GovernorMiddleware

pub struct GovernorMiddleware { /* fields omitted */ }

Once the rate limit has been reached, the middleware will respond with status code 429 (too many requests) and a Retry-After header with the amount of time that needs to pass before another request will be allowed.

Implementations

impl GovernorMiddleware[src]

#[must_use]pub fn with_period(duration: Duration) -> Option<Self>[src]

Constructs a rate-limiting middleware from a Duration that allows one request in the given time interval.

If the time interval is zero, returns None.

pub fn per_second<T>(times: T) -> Result<Self> where
    T: TryInto<NonZeroU32>,
    T::Error: Error + Send + Sync + 'static, 
[src]

Constructs a rate-limiting middleware that allows a specified number of requests every second.

Returns an error if times can't be converted into a NonZeroU32.

pub fn per_minute<T>(times: T) -> Result<Self> where
    T: TryInto<NonZeroU32>,
    T::Error: Error + Send + Sync + 'static, 
[src]

Constructs a rate-limiting middleware that allows a specified number of requests every minute.

Returns an error if times can't be converted into a NonZeroU32.

pub fn per_hour<T>(times: T) -> Result<Self> where
    T: TryInto<NonZeroU32>,
    T::Error: Error + Send + Sync + 'static, 
[src]

Constructs a rate-limiting middleware that allows a specified number of requests every hour.

Returns an error if times can't be converted into a NonZeroU32.

Trait Implementations

impl Clone for GovernorMiddleware[src]

impl Debug for GovernorMiddleware[src]

impl<State: Clone + Send + Sync + 'static> Middleware<State> for GovernorMiddleware[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> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,