pub struct RateLimiter { /* private fields */ }Expand description
Wraps rate limit database operations with a clean API.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub async fn can_reply(&self) -> Result<bool, StorageError>
pub async fn can_reply(&self) -> Result<bool, StorageError>
Check if a reply action is allowed under the current rate limit.
Sourcepub async fn can_tweet(&self) -> Result<bool, StorageError>
pub async fn can_tweet(&self) -> Result<bool, StorageError>
Check if a tweet action is allowed under the current rate limit.
Sourcepub async fn can_thread(&self) -> Result<bool, StorageError>
pub async fn can_thread(&self) -> Result<bool, StorageError>
Check if a thread action is allowed under the current rate limit.
Sourcepub async fn can_search(&self) -> Result<bool, StorageError>
pub async fn can_search(&self) -> Result<bool, StorageError>
Check if a search action is allowed under the current rate limit.
Sourcepub async fn record_reply(&self) -> Result<(), StorageError>
pub async fn record_reply(&self) -> Result<(), StorageError>
Record a successful reply action (increments counter).
Sourcepub async fn record_tweet(&self) -> Result<(), StorageError>
pub async fn record_tweet(&self) -> Result<(), StorageError>
Record a successful tweet action (increments counter).
Sourcepub async fn record_thread(&self) -> Result<(), StorageError>
pub async fn record_thread(&self) -> Result<(), StorageError>
Record a successful thread action (increments counter).
Sourcepub async fn record_search(&self) -> Result<(), StorageError>
pub async fn record_search(&self) -> Result<(), StorageError>
Record a successful search action (increments counter).
Sourcepub async fn acquire_posting_permit(
&self,
action_type: &str,
) -> Result<bool, StorageError>
pub async fn acquire_posting_permit( &self, action_type: &str, ) -> Result<bool, StorageError>
Atomically check and claim a rate limit slot.
Returns Ok(true) if permitted (counter incremented),
Ok(false) if the rate limit is reached.
Preferred over separate check + record for posting actions.
Auto Trait Implementations§
impl Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin for RateLimiter
impl !UnwindSafe for RateLimiter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more