Trait Storage

Source
pub trait Storage {
    type Error: From<RateLimitExceededError>;

    // Required method
    fn try_acquire(
        &self,
        alg: TokenBucketAlgorithm,
        permits: u32,
    ) -> Result<(), Self::Error>;
}
Expand description

Trait that provides function for tokens acquiring.

Object that implements this trait should load state, execute provided algorithm and save updated state.

Required Associated Types§

Required Methods§

Source

fn try_acquire( &self, alg: TokenBucketAlgorithm, permits: u32, ) -> Result<(), Self::Error>

Implementors§

Source§

impl Storage for DistributedStorage

Available on crate feature distributed-impl only.
Source§

impl Storage for InMemoryStorage

Source§

impl Storage for RedisStorage

Available on crate feature redis-impl only.