pub struct FixedRingBuffer<T> { /* private fields */ }
Expand description
A ring-buffer with a size determined at creation-time
This makes it perfectly suited for buffers that produce and consume at different speeds.
Implementations§
Source§impl<T> FixedRingBuffer<T>
impl<T> FixedRingBuffer<T>
pub fn new(capacity: usize) -> Self
pub const fn len(&self) -> usize
pub const fn capacity(&self) -> usize
pub const fn remaining_capacity(&self) -> usize
pub const fn is_empty(&self) -> bool
pub const fn is_full(&self) -> bool
Sourcepub fn as_slices(&self) -> (&[T], &[T])
pub fn as_slices(&self) -> (&[T], &[T])
Get a reference to all elements in the form of two slices.
These are in the listed in the order of being pushed into the buffer.
Sourcepub fn pop_front(&mut self) -> Option<T>
pub fn pop_front(&mut self) -> Option<T>
Pop an item at the front of the FixedRingBuffer
Sourcepub fn push(&mut self, value: T) -> Option<()>
pub fn push(&mut self, value: T) -> Option<()>
Push an item into the FixedRingBuffer
Returns None
if there is no more space
Source§impl<T: Copy> FixedRingBuffer<T>
impl<T: Copy> FixedRingBuffer<T>
Sourcepub fn fill_repeat(&mut self, value: T, num: usize) -> usize
pub fn fill_repeat(&mut self, value: T, num: usize) -> usize
Add at most num
items of value
into the FixedRingBuffer
This returns the amount of items actually added.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for FixedRingBuffer<T>
impl<T> RefUnwindSafe for FixedRingBuffer<T>where
T: RefUnwindSafe,
impl<T> !Send for FixedRingBuffer<T>
impl<T> !Sync for FixedRingBuffer<T>
impl<T> Unpin for FixedRingBuffer<T>
impl<T> UnwindSafe for FixedRingBuffer<T>where
T: RefUnwindSafe,
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