Skip to main content

RateLimitBackend

Trait RateLimitBackend 

Source
pub trait RateLimitBackend:
    Send
    + Sync
    + Debug {
    // Required method
    fn increment_and_get(
        &self,
        key: &str,
        window_secs: u64,
    ) -> Result<u64, ServerError>;
}
Available on crate feature distributed-rate-limit only.
Expand description

Backend trait for incrementing a rate-limit key in a time window.

§Examples

use http_handle::distributed_rate_limit::RateLimitBackend;
assert_eq!(2 + 2, 4);

§Panics

Trait usage does not panic by itself.

Required Methods§

Source

fn increment_and_get( &self, key: &str, window_secs: u64, ) -> Result<u64, ServerError>

Increments key and returns current hit count for the active window.

Implementors§