Trait rocket_governor::RocketGovernable[][src]

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

    fn nonzero(n: u32) -> NonZeroU32 { ... }
}
Expand description

The RocketGovernable guard trait.

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

Declare a struct and use it with the generic RocketGovernor guard. This requires to implement RocketGovernable for your struct.

See the top level crate documentation.

Required methods

Returns the Quota of the RocketGovernable.

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

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

Provided methods

Converts a non-zero number u32 to NonZeroU32.

Number zero/0 becomes 1.

Implementors