futures_intrusive::buffer

Struct ArrayBuf

Source
pub struct ArrayBuf<T, A>
where A: AsMut<[T]> + AsRef<[T]> + RealArray<T>,
{ /* private fields */ }
Expand description

An array-backed Ring Buffer

A is the type of the backing array. The backing array must be a real array. In order to verify this it must satisfy the RealArray constraint. In order to create a Ring Buffer backed by an array of 5 integer elements, the following code can be utilized:

use futures_intrusive::buffer::{ArrayBuf, RingBuf};

type Buffer5 = ArrayBuf<i32, [i32; 5]>;
let buffer = Buffer5::new();

Trait Implementations§

Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Source§

type Item = T

The type of stored items inside the Ring Buffer
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, value: 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.
Source§

fn is_empty(&self) -> bool

Returns true if no item is stored inside the buffer.

Auto Trait Implementations§

§

impl<T, A> Freeze for ArrayBuf<T, A>
where A: Freeze,

§

impl<T, A> RefUnwindSafe for ArrayBuf<T, A>

§

impl<T, A> Send for ArrayBuf<T, A>
where T: Send, A: Send,

§

impl<T, A> Sync for ArrayBuf<T, A>
where T: Sync, A: Sync,

§

impl<T, A> Unpin for ArrayBuf<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnwindSafe for ArrayBuf<T, A>
where T: UnwindSafe, A: 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, 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.