Skip to main content

haste_rate_limit/
lib.rs

1use std::pin::Pin;
2
3pub enum RateLimitError {
4    Error(String),
5    Exceeded,
6}
7
8pub trait RateLimit: Sync + Send {
9    fn check<'a>(
10        &'a self,
11        rate_key: &'a str,
12        max: i32,
13        points: i32,
14        window_in_seconds: i32,
15    ) -> Pin<Box<dyn Future<Output = Result<i32, RateLimitError>> + Send + 'a>>;
16}