futures_intrusive::buffer

Trait RingBuf

Source
pub trait RingBuf {
    type Item;

    // Required methods
    fn new() -> Self;
    fn with_capacity(cap: usize) -> Self;
    fn capacity(&self) -> usize;
    fn len(&self) -> usize;
    fn can_push(&self) -> bool;
    fn push(&mut self, item: Self::Item);
    fn pop(&mut self) -> Self::Item;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A Ring Buffer of items

Required Associated Types§

Source

type Item

The type of stored items inside the Ring Buffer

Required Methods§

Source

fn new() -> Self

Creates a new instance of the Ring Buffer

Source

fn with_capacity(cap: usize) -> Self

Creates a new instance of the Ring Buffer with the given capacity. RingBuf implementations are allowed to ignore the capacity hint and utilize their default capacity.

Source

fn capacity(&self) -> usize

The capacity of the buffer

Source

fn len(&self) -> usize

The amount of stored items in the buffer

Source

fn can_push(&self) -> bool

Returns true if there is enough space in the buffer to store another item.

Source

fn push(&mut self, item: Self::Item)

Stores the item at the end of the buffer. Panics if there is not enough free space.

Source

fn pop(&mut self) -> Self::Item

Returns the oldest item inside the buffer. Panics if there is no available item.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if no item is stored inside the buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> RingBuf for FixedHeapBuf<T>

Source§

type Item = T

Source§

impl<T> RingBuf for GrowingHeapBuf<T>

Source§

type Item = T

Source§

impl<T, A> RingBuf for ArrayBuf<T, A>
where A: AsMut<[T]> + AsRef<[T]> + RealArray<T>,

Source§

type Item = T