pub struct BoundedRing { /* private fields */ }Expand description
A fixed-capacity byte ring. On overflow the oldest bytes are dropped (never blocks the writer) and counted so the consumer can surface backpressure.
Implementations§
Source§impl BoundedRing
impl BoundedRing
pub fn new(capacity: usize) -> Self
Sourcepub fn extend(&mut self, data: &[u8])
pub fn extend(&mut self, data: &[u8])
Append data, dropping the oldest bytes if it would exceed capacity.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
Sourcepub fn dropped_bytes(&self) -> u64
pub fn dropped_bytes(&self) -> u64
Total bytes dropped due to overflow over this ring’s lifetime.
Sourcepub fn total_written(&self) -> u64
pub fn total_written(&self) -> u64
Total bytes ever written to the ring (dropped + currently buffered).
This is a monotonic cursor: a reader that remembers the next value
from BoundedRing::read_since can ask for everything appended since,
without the fragile two-snapshot diff a sliding window would otherwise
require. Drive output streaming (Wave 4) rides on this.
Sourcepub fn read_since(&self, cursor: u64) -> ReadSince
pub fn read_since(&self, cursor: u64) -> ReadSince
Return everything appended after the absolute byte offset cursor.
next is the offset to pass on the following call. gap is true when
cursor pointed at bytes the ring has since dropped (overflow), so the
reader knows its stream skipped ahead and can surface a drop notice
rather than silently splicing non-contiguous output. A cursor past the
current tail (a reader ahead of the writer, or a stale-but-future value)
yields no bytes and next == cursor.max(total).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoundedRing
impl RefUnwindSafe for BoundedRing
impl Send for BoundedRing
impl Sync for BoundedRing
impl Unpin for BoundedRing
impl UnsafeUnpin for BoundedRing
impl UnwindSafe for BoundedRing
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.