Skip to main content

rs_auth_core/
rate_limit.rs

1use async_trait::async_trait;
2
3use crate::error::AuthError;
4
5#[derive(Debug, Clone)]
6pub enum RateLimitAction {
7    Signup,
8    Login,
9    PasswordReset,
10    OAuthCallback,
11}
12
13#[async_trait]
14pub trait RateLimiter: Send + Sync {
15    async fn check(&self, action: RateLimitAction, key: &str) -> Result<(), AuthError> {
16        let _ = (action, key);
17        Ok(())
18    }
19}
20
21pub struct NoOpRateLimiter;
22
23#[async_trait]
24impl RateLimiter for NoOpRateLimiter {}