Trait rocket_governor::RocketGovernable[][src]

pub trait RocketGovernable<'r>: FromRequest<'r> + Default {
    fn quota(method: Method, route_name: &str) -> Quota;

    fn rocket_governor_catcher<'c>(request: &'c Request<'_>) -> &'c LimitError { ... }
fn nonzero(n: u32) -> NonZeroU32 { ... } }
Expand description

rocket_governor is a rocket guard implementation of the governor rate limiter.

It is used with the derive macro rocket_governor_derive.

Declare a struct with #[derive(RocketGovernor)] and implement the missing methods.

Required methods

Returns the Quota of the rocket_governor

This is called only once per method/route_name combination. So it makes only sense to return always the same Quota for this combination and no dynamic calculation.

This is also the requirement to have correct information set in HTTP headers by registered too_many_requests_catcher(&Request).

Provided methods

Converts a non-zero number u32 to NonZeroU32

Number zero/0 becomes 1

Implementors