Skip to main content

Bucket

Struct Bucket 

Source
pub struct Bucket<K, C = SystemClock> { /* private fields */ }
Expand description

A sliding-window counter per key, holding at most Limits::capacity keys.

Implementations§

Source§

impl<K: Eq + Hash + Clone> Bucket<K, SystemClock>

Source

pub fn new(limits: Limits) -> Self

Source§

impl<K: Eq + Hash + Clone, C: Clock> Bucket<K, C>

Source

pub fn with_clock(limits: Limits, clock: C) -> Self

Source

pub fn check(&mut self, key: &K) -> Decision

Records an attempt for key and says whether it may proceed.

Source

pub fn tracked(&self) -> usize

Keys currently tracked. Exposed for metrics and tests.

Auto Trait Implementations§

§

impl<K, C> Freeze for Bucket<K, C>
where C: Freeze,

§

impl<K, C> RefUnwindSafe for Bucket<K, C>

§

impl<K, C> Send for Bucket<K, C>
where C: Send, K: Send,

§

impl<K, C> Sync for Bucket<K, C>
where C: Sync, K: Sync,

§

impl<K, C> Unpin for Bucket<K, C>
where C: Unpin, K: Unpin,

§

impl<K, C> UnsafeUnpin for Bucket<K, C>
where C: UnsafeUnpin,

§

impl<K, C> UnwindSafe for Bucket<K, C>
where C: UnwindSafe, K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.