pub struct RingBuffer<T>where
T: Clone,{ /* private fields */ }Expand description
Fixed-size ring buffer with metrics
Implementations§
Source§impl<T> RingBuffer<T>where
T: Clone,
impl<T> RingBuffer<T>where
T: Clone,
Sourcepub fn new(capacity: usize) -> RingBuffer<T>
pub fn new(capacity: usize) -> RingBuffer<T>
Create a new ring buffer with given capacity
Sourcepub fn push(&mut self, item: T) -> bool
pub fn push(&mut self, item: T) -> bool
Push an item into the buffer Returns true if item was added, false if buffer was full and old item was dropped
Sourcepub fn metrics(&self) -> Arc<RingBufferMetrics>
pub fn metrics(&self) -> Arc<RingBufferMetrics>
Get metrics reference
Auto Trait Implementations§
impl<T> Freeze for RingBuffer<T>
impl<T> RefUnwindSafe for RingBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for RingBuffer<T>where
T: Send,
impl<T> Sync for RingBuffer<T>where
T: Sync,
impl<T> Unpin for RingBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for RingBuffer<T>
impl<T> UnwindSafe for RingBuffer<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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more