Struct ratelimit_meter::example_algorithms::Allower
source · pub struct Allower {}
Expand description
The most naive implementation of a rate-limiter ever: Always allows every cell through.
Example
use ratelimit_meter::{Decider};
use ratelimit_meter::example_algorithms::Allower;
let mut allower = Allower::new();
assert!(allower.check().is_ok());
Implementations
Trait Implementations
sourceimpl Decider for Allower
impl Decider for Allower
sourceimpl MultiDecider for Allower
impl MultiDecider for Allower
sourcefn check_n_at(&mut self, n: u32, at: Instant) -> Result<(), NegativeMultiDecision>
fn check_n_at(&mut self, n: u32, at: Instant) -> Result<(), NegativeMultiDecision>
Tests if
n
cells can be accommodated at the given time
stamp. If (and only if) all cells in the batch can be
accomodated, the MultiDecider
updates the internal state to
account for all cells and returns Ok(())
. Read moresourcefn check_n(&mut self, n: u32) -> Result<(), NegativeMultiDecision>
fn check_n(&mut self, n: u32) -> Result<(), NegativeMultiDecision>
Tests if
n
cells can be accommodated at the current time
(Instant::now()
), using check_n_at
Read moreimpl Copy for Allower
Auto Trait Implementations
impl RefUnwindSafe for Allower
impl Send for Allower
impl Sync for Allower
impl Unpin for Allower
impl UnwindSafe for Allower
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