pub struct RingBuf<T> { /* private fields */ }
Expand description
ring buffer supporting batch copy in/out
safety: probably not
Implementations§
Source§impl<T> RingBuf<T>
impl<T> RingBuf<T>
Sourcepub fn with_capacity(capacity: usize) -> RingBuf<T>
pub fn with_capacity(capacity: usize) -> RingBuf<T>
create new buffer with preallocated capacity
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
determine if elements in backing buffer are in a contiguous segment
Sourcepub fn realign(&mut self)
pub fn realign(&mut self)
realign all elements so they are contiguous at the beginning of the buffer
Sourcepub fn reserve_exact(&mut self, count: usize)
pub fn reserve_exact(&mut self, count: usize)
reserve space for exactly count
more elements (see Vec::reserve_exact)
Sourcepub fn push_front(&mut self, val: T)
pub fn push_front(&mut self, val: T)
push one element to front of ring
Sourcepub fn range(&self, range: Range<usize>) -> RingBufSlice<'_, T>
pub fn range(&self, range: Range<usize>) -> RingBufSlice<'_, T>
get immutable reference to range
Sourcepub fn range_mut(&mut self, range: Range<usize>) -> RingBufSliceMut<'_, T>
pub fn range_mut(&mut self, range: Range<usize>) -> RingBufSliceMut<'_, T>
get mutable reference to range
Source§impl<T: Clone> RingBuf<T>
impl<T: Clone> RingBuf<T>
Sourcepub fn fill_at_back(&mut self, count: usize, value: T)
pub fn fill_at_back(&mut self, count: usize, value: T)
append count
elements at back by cloning
Sourcepub fn fill_at_front(&mut self, count: usize, value: T)
pub fn fill_at_front(&mut self, count: usize, value: T)
prepend count
elements at front by cloning
Source§impl<T: Copy> RingBuf<T>
impl<T: Copy> RingBuf<T>
Sourcepub fn push_back_copy_from_slice(&mut self, elements: &[T])
pub fn push_back_copy_from_slice(&mut self, elements: &[T])
push contents of slice to back by copying
Sourcepub fn push_front_copy_from_slice(&mut self, elements: &[T])
pub fn push_front_copy_from_slice(&mut self, elements: &[T])
push contents of slice to front by copying
Sourcepub fn pop_back_copy_to_slice(&mut self, dest: &mut [T])
pub fn pop_back_copy_to_slice(&mut self, dest: &mut [T])
pop contents to slice from back by copying
Sourcepub fn pop_front_copy_to_slice(&mut self, dest: &mut [T])
pub fn pop_front_copy_to_slice(&mut self, dest: &mut [T])
pop contents to slice from front by copying
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for RingBuf<T>
impl<T> RefUnwindSafe for RingBuf<T>where
T: RefUnwindSafe,
impl<T> Send for RingBuf<T>where
T: Send,
impl<T> Sync for RingBuf<T>where
T: Sync,
impl<T> Unpin for RingBuf<T>where
T: Unpin,
impl<T> UnwindSafe for RingBuf<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