[][src]Struct kernel::common::ring_buffer::RingBuffer

pub struct RingBuffer<'a, T: 'a> {
    ring: &'a mut [T],
    head: usize,
    tail: usize,


ring: &'a mut [T]head: usizetail: usize


impl<'a, T: Copy> RingBuffer<'a, T>[src]

pub fn new(ring: &'a mut [T]) -> RingBuffer<'a, T>[src]

pub fn available_len(&self) -> usize[src]

Returns the number of elements that can be enqueued until the ring buffer is full.

pub fn as_slices(&'a self) -> (Option<&'a [T]>, Option<&'a [T]>)[src]

Returns up to 2 slices that together form the contents of the ring buffer.


  • (None, None) if the buffer is empty.
  • (Some(slice), None) if the head is before the tail (therefore all the contents is contiguous).
  • (Some(left), Some(right)) if the head is after the tail. In that case, the logical contents of the buffer is [left, right].concat() (although physically the "left" slice is stored after the "right" slice).

Trait Implementations

impl<'a, T: Copy> Queue<T> for RingBuffer<'a, T>[src]

Auto Trait Implementations

impl<'a, T> Unpin for RingBuffer<'a, T>

impl<'a, T> Send for RingBuffer<'a, T> where
    T: Send

impl<'a, T> Sync for RingBuffer<'a, T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

The type returned in the event of a conversion error.

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

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

impl<T> Any for T where
    T: 'static + ?Sized