[][src]Struct indexed_ring_buffer::RingBuffer

pub struct RingBuffer<T> { /* fields omitted */ }

An indexed multiple readable spsc ring buffer.

  • access by an absolute index.
  • a Single-Producer Single-Consumer with Multi-Reader
  • using RwLock of parking_lot
extern crate indexed_ring_buffer;
use indexed_ring_buffer::*;

let (mut p, mut c, r) = indexed_ring_buffer::<usize>(0, 5);
for i in 0..101 {
    p.push(i);
    c.shift();
}

for i in 101..106 {
    p.push(i);
}

let (start, end, data) = r.get_from(101,5).unwrap();
assert_eq!(data,vec![101,102,103,104,105]);
assert_eq!(start,101);
assert_eq!(end,105);

c.shift_to(105);
let rslt = r.get_all();
assert_eq!(rslt,None);

Ring buffer itself.

Methods

impl<T> RingBuffer<T> where
    T: Sized + Default + Clone + Copy
[src]

pub fn new(offset: usize, size: usize) -> RingBuffer<T>[src]

Creates a new instance of a ring buffer.

pub fn get_ref(&self) -> &[MaybeUninit<T>][src]

pub fn get_mut(&self) -> &mut [MaybeUninit<T>][src]

pub fn is_empty(&self) -> bool[src]

Checks if the ring buffer is empty.

pub fn is_full(&self) -> bool[src]

Checks if the ring buffer is full.

Auto Trait Implementations

impl<T> !RefUnwindSafe for RingBuffer<T>

impl<T> Send for RingBuffer<T> where
    T: Send

impl<T> !Sync for RingBuffer<T>

impl<T> Unpin for RingBuffer<T>

impl<T> UnwindSafe for RingBuffer<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.