actix-rate-limit 0.3.1

Rate-Limit middleware for actix-web
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::future::Future;

pub type LimitType = u32;

pub trait RateLimitId: serde::de::DeserializeOwned + std::fmt::Display {}

impl<Id: serde::de::DeserializeOwned + std::fmt::Display> RateLimitId for Id {}

pub trait RateLimitBackend {
    type Error;

    type Future: Future<Output = Result<LimitType, Self::Error>>;

    fn touch(&self, id: &str, limit: LimitType) -> Self::Future;
}