pub struct MonotonicCounter { /* private fields */ }Expand description
A simple counter that increases by one for each call to next() up to a fixed limit. It never
wraps around, reusing a counter value would break the uniqueness required by
FrameCounter - instead it is exhausted after the limit was reached, see
MonotonicCounter::is_exhausted. Per Default the limit is u64::MAX.
Implementations§
Source§impl MonotonicCounter
impl MonotonicCounter
Sourcepub fn new(max_counter: u64) -> Self
pub fn new(max_counter: u64) -> Self
Creates a new counter which is exhausted after max_counter was returned.
Sourcepub fn with_start_value(start_value: u64, max_counter: u64) -> Self
pub fn with_start_value(start_value: u64, max_counter: u64) -> Self
Creates a new counter with a start value which is exhausted after max_counter was
returned.
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Returns true if all counter values were used up, i.e. the next call to
FrameCounter::next will panic.
Trait Implementations§
Source§impl Clone for MonotonicCounter
impl Clone for MonotonicCounter
Source§fn clone(&self) -> MonotonicCounter
fn clone(&self) -> MonotonicCounter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MonotonicCounter
Source§impl Debug for MonotonicCounter
impl Debug for MonotonicCounter
Source§impl Default for MonotonicCounter
impl Default for MonotonicCounter
Source§impl FrameCounter for MonotonicCounter
impl FrameCounter for MonotonicCounter
Auto Trait Implementations§
impl Freeze for MonotonicCounter
impl RefUnwindSafe for MonotonicCounter
impl Send for MonotonicCounter
impl Sync for MonotonicCounter
impl Unpin for MonotonicCounter
impl UnsafeUnpin for MonotonicCounter
impl UnwindSafe for MonotonicCounter
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