Skip to main content

SendBudget

Trait SendBudget 

Source
pub trait SendBudget: Send + Sync {
    // Required methods
    fn check<'life0, 'async_trait>(
        &'life0 self,
        now: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record<'life0, 'async_trait>(
        &'life0 self,
        now: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The challenge-send budget (SEND_COOLDOWN_SECS, MAX_SENDS_PER_HOUR). Injectable so the caller decides its scope and storage: the CLI keeps one per user in a file; a daemon keeps one per org.

Required Methods§

Source

fn check<'life0, 'async_trait>( &'life0 self, now: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fail with rate_limited if a send now would break the limits.

Source

fn record<'life0, 'async_trait>( &'life0 self, now: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record a send. Called before the send happens (a crash still counts); an error aborts the login before anything is sent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§