pub struct BoundedRing<T> { /* private fields */ }Expand description
A bounded first-in first-out queue that evicts its oldest entry on a push into a full queue and counts every eviction.
Implementations§
Source§impl<T> BoundedRing<T>
impl<T> BoundedRing<T>
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
An empty ring holding at most capacity entries (at least one).
Sourcepub fn push(&mut self, entry: T) -> bool
pub fn push(&mut self, entry: T) -> bool
Appends entry, evicting and counting the oldest entry when full.
Answers whether an entry was evicted.
Sourcepub fn take(&mut self) -> (Drain<'_, T>, u64)
pub fn take(&mut self) -> (Drain<'_, T>, u64)
Removes every held entry, oldest first, with the evictions since the previous take; the next take counts from zero again.
Sourcepub const fn dropped_since_take(&self) -> u64
pub const fn dropped_since_take(&self) -> u64
Entries evicted since the previous take.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for BoundedRing<T>
impl<T> RefUnwindSafe for BoundedRing<T>where
VecDeque<T>: RefUnwindSafe,
impl<T> Send for BoundedRing<T>
impl<T> Sync for BoundedRing<T>
impl<T> Unpin for BoundedRing<T>
impl<T> UnsafeUnpin for BoundedRing<T>where
VecDeque<T>: UnsafeUnpin,
impl<T> UnwindSafe for BoundedRing<T>where
VecDeque<T>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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