revolt_database/models/ratelimit_events/
ops.rs

1use std::time::Duration;
2
3use crate::{revolt_result::Result, RatelimitEvent, RatelimitEventType};
4
5#[cfg(feature = "mongodb")]
6mod mongodb;
7mod reference;
8
9#[async_trait]
10pub trait AbstractRatelimitEvents: Sync + Send {
11    /// Insert a new ratelimit event
12    async fn insert_ratelimit_event(&self, event: &RatelimitEvent) -> Result<()>;
13
14    /// Count number of events in given duration and check if we've hit the limit
15    async fn has_ratelimited(
16        &self,
17        target_id: &str,
18        event_type: RatelimitEventType,
19        period: Duration,
20        count: usize,
21    ) -> Result<bool>;
22}