kinesin_rdt::common::ring_buffer

Struct RingBuf

Source
pub struct RingBuf<T> { /* private fields */ }
Expand description

ring buffer supporting batch copy in/out

safety: probably not

Implementations§

Source§

impl<T> RingBuf<T>

Source

pub fn new() -> RingBuf<T>

create new buffer

Source

pub fn with_capacity(capacity: usize) -> RingBuf<T>

create new buffer with preallocated capacity

Source

pub fn capacity(&self) -> usize

max capacity before reallocating

Source

pub fn len(&self) -> usize

length of buffer

Source

pub fn is_empty(&self) -> bool

whether buffer is empty

Source

pub fn is_contiguous(&self) -> bool

determine if elements in backing buffer are in a contiguous segment

Source

pub fn realign(&mut self)

realign all elements so they are contiguous at the beginning of the buffer

Source

pub fn reserve(&mut self, count: usize)

reserve space for at least count more elements

Source

pub fn reserve_exact(&mut self, count: usize)

reserve space for exactly count more elements (see Vec::reserve_exact)

Source

pub fn shrink_to(&mut self, target_capacity: usize)

shrink backing buffer to given capacity

Source

pub fn push_back(&mut self, val: T)

push one element to back of ring

Source

pub fn push_front(&mut self, val: T)

push one element to front of ring

Source

pub fn pop_back(&mut self) -> Option<T>

pop one element from back of ring

Source

pub fn pop_front(&mut self) -> Option<T>

pop one element from front of ring

Source

pub fn range(&self, range: Range<usize>) -> RingBufSlice<'_, T>

get immutable reference to range

Source

pub fn range_mut(&mut self, range: Range<usize>) -> RingBufSliceMut<'_, T>

get mutable reference to range

Source

pub fn get(&self, index: usize) -> Option<&T>

obtain reference to element at provided index

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

obtain mutable reference to element at provided index

Source

pub fn clear(&mut self)

clear all elements

Source

pub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> Drain<'_, T>

remove range of elements from RingBuf and return iterator for those elements

Currently only supports draining from either the start or the end. Drained elements are dropped when the iterator is dropped.

Source§

impl<T: Clone> RingBuf<T>

Source

pub fn fill_at_back(&mut self, count: usize, value: T)

append count elements at back by cloning

Source

pub fn fill_at_front(&mut self, count: usize, value: T)

prepend count elements at front by cloning

Source§

impl<T: Copy> RingBuf<T>

Source

pub fn push_back_copy_from_slice(&mut self, elements: &[T])

push contents of slice to back by copying

Source

pub fn push_front_copy_from_slice(&mut self, elements: &[T])

push contents of slice to front by copying

Source

pub fn pop_back_copy_to_slice(&mut self, dest: &mut [T])

pop contents to slice from back by copying

Source

pub fn pop_front_copy_to_slice(&mut self, dest: &mut [T])

pop contents to slice from front by copying

Trait Implementations§

Source§

impl<T> Drop for RingBuf<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more