Struct ratelimit_meter::state::direct::Builder
source · Expand description
An object that allows incrementally constructing rate Limiter objects.
Implementations
sourceimpl<A> Builder<A>where
A: Algorithm + Sized,
impl<A> Builder<A>where
A: Algorithm + Sized,
sourcepub fn cell_weight(
&mut self,
weight: NonZeroU32
) -> Result<&mut Builder<A>, InconsistentCapacity>
pub fn cell_weight(
&mut self,
weight: NonZeroU32
) -> Result<&mut Builder<A>, InconsistentCapacity>
Sets the “weight” of each cell being checked against the bucket. Each cell fills the bucket by this much.
sourcepub fn per(&mut self, time_unit: Duration) -> &mut Builder<A>
pub fn per(&mut self, time_unit: Duration) -> &mut Builder<A>
Sets the “unit of time” within which the bucket drains.
The assumption is that in a period of time_unit
(if no cells
are being checked), the bucket is fully drained.
sourcepub fn build(&self) -> Result<DirectRateLimiter<A>, InconsistentCapacity>
pub fn build(&self) -> Result<DirectRateLimiter<A>, InconsistentCapacity>
Builds a rate limiter of the specified type.
Auto Trait Implementations
impl<T> RefUnwindSafe for Builder<T>where
T: RefUnwindSafe,
impl<T> Send for Builder<T>
impl<T> Sync for Builder<T>
impl<T> Unpin for Builder<T>where
T: Unpin,
impl<T> UnwindSafe for Builder<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more