pub struct Ring<T> { /* private fields */ }Expand description
Fixed-capacity append-only ring for process-local mirrors. capacity == 0
means “disabled” (stores nothing, hands each item straight back), the
correct default when a durable store is authoritative.
Clone produces a snapshot with its OWN independent SizeGauge, seeded to
the current length. push is public, so a clone can be appended to; giving
the clone a fresh gauge guarantees that writing through a snapshot (for
example the public append on a receipt_log() snapshot) can never corrupt
the owning structure’s telemetry gauge.
Implementations§
Source§impl<T> Ring<T>
impl<T> Ring<T>
pub fn with_capacity(capacity: usize, gauge: SizeGauge) -> Self
Sourcepub fn push(&mut self, item: T) -> Option<T>
pub fn push(&mut self, item: T) -> Option<T>
Push, evicting the oldest entry when at capacity. Returns the evicted
item (if any) so callers may act before it drops. Never grows past
capacity.
pub fn iter(&self) -> impl Iterator<Item = &T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Ring<T>
impl<T> RefUnwindSafe for Ring<T>where
T: RefUnwindSafe,
impl<T> Send for Ring<T>where
T: Send,
impl<T> Sync for Ring<T>where
T: Sync,
impl<T> Unpin for Ring<T>where
T: Unpin,
impl<T> UnsafeUnpin for Ring<T>
impl<T> UnwindSafe for Ring<T>where
T: UnwindSafe,
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