Trait ratelimit_meter::Decider
source · pub trait Decider: Sized + DeciderImpl {
fn check(&mut self) -> Result<(), NonConformance> { ... }
fn check_at(&mut self, at: Instant) -> Result<(), NonConformance> { ... }
}
Expand description
The main decision trait. It allows checking a single cell against
the rate-limiter, either at the current time instant, or at a
given instant in time, updating the Decider
’s internal state if
the cell is conforming.
Provided Methods
sourcefn check(&mut self) -> Result<(), NonConformance>
fn check(&mut self) -> Result<(), NonConformance>
Tests if a single cell can be accommodated at
Instant::now()
. If it can be, check
updates the Decider
to account for the conforming cell and returns Ok(())
.
If the cell is non-conforming (i.e., it can’t be accomodated
at this time stamp), check_at
returns Err
with information
about the earliest time at which a cell could be considered
conforming (see NonConformance
).