struct Ring {
head: i64,
counts: [u32; 24],
}Expand description
A ring of hourly counters, newest at head.
Fields§
§head: i64§counts: [u32; 24]Implementations§
Source§impl Ring
impl Ring
fn new(at: i64) -> Self
Sourcefn advance(&mut self, at: i64)
fn advance(&mut self, at: i64)
Moves the head to at, clearing the buckets passed on the way. An
instant at or before the head leaves the head where it is: now is
supplied per write, and a write presented with an earlier instant
than one already counted lands in the newest bucket rather than
reopening a bucket that has closed.
fn read(&self, window: Window) -> u64
Sourcefn add(&mut self)
fn add(&mut self)
Counts one more in the newest bucket. Saturates: something that has
reached u32::MAX in an hour is past every limit there is, and
wrapping would put it back under one.
fn aged_out(&self, at: i64) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ring
impl RefUnwindSafe for Ring
impl Send for Ring
impl Sync for Ring
impl Unpin for Ring
impl UnsafeUnpin for Ring
impl UnwindSafe for Ring
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more