Struct eternity::Bucket [−][src]
This type checks for rate limits on Key
s.
If caching is enabled, it will cache values.
Implementations
impl<Key: Hash + PartialEq + Clone + Eq + Send + Sync, Value: Clone + Send> Bucket<Key, Value>
[src]
pub async fn hit_limit(&mut self, key: &Key) -> Option<RateLimitInfo<Value>>
[src]
Tries to perform a hit in the bucket.
If no hit can be performed, this method will return the rate limit.
Otherwise, the method will return None
.
pub async fn hit_or_cache(
&mut self,
key: &Key,
function: impl Future<Output = Option<Value>> + Send
) -> Option<Value>
[src]
&mut self,
key: &Key,
function: impl Future<Output = Option<Value>> + Send
) -> Option<Value>
First, checks the bucket for a potential rate limit.
If a rate limit applies, it will clone the cached value.
If no value is cached, this method returns None
.
If no rate limit applies, this method will run function
and
if some value is returned by that function, caches the value.
pub async fn add_cache_value(&mut self, key: &Key, value: Value)
[src]
Inserts a cache value into the group of key
.
Auto Trait Implementations
impl<Key, Value> RefUnwindSafe for Bucket<Key, Value> where
Key: RefUnwindSafe,
Value: RefUnwindSafe,
Key: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Key, Value> Send for Bucket<Key, Value>
impl<Key, Value> Sync for Bucket<Key, Value> where
Value: Sync,
Value: Sync,
impl<Key, Value> Unpin for Bucket<Key, Value> where
Key: Unpin,
Value: Unpin,
Key: Unpin,
Value: Unpin,
impl<Key, Value> UnwindSafe for Bucket<Key, Value> where
Key: UnwindSafe,
Value: UnwindSafe,
Key: UnwindSafe,
Value: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,