Trait Storage

Source
pub trait Storage<T>: Sized {
    type Output;

    // Required methods
    fn insert(&mut self, index: usize, item: T);
    fn finish(self, pushed: usize) -> Result<Self::Output, Self>;

    // Provided methods
    fn reserve(&mut self, len: usize) { ... }
    fn bounds(&self) -> (Option<usize>, Option<usize>) { ... }
}
Expand description

Backing storage for pull operations

Required Associated Types§

Required Methods§

Source

fn insert(&mut self, index: usize, item: T)

Insert an item into a storage slot

index is the index of this push operation since the call to Consumer::try_recv_*.

Source

fn finish(self, pushed: usize) -> Result<Self::Output, Self>

Called to seal the storage after all negociated items have been received

The negociated number of items is available as pushed.

Provided Methods§

Source

fn reserve(&mut self, len: usize)

Pre-allocate space for len additional items

Source

fn bounds(&self) -> (Option<usize>, Option<usize>)

Specify the number of items that this storage can handle

The value must be returned as (minimum, maximum).

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.

Implementations on Foreign Types§

Source§

impl<T> Storage<T> for &mut [T]

Source§

type Output = ()

Source§

fn insert(&mut self, index: usize, item: T)

Source§

fn bounds(&self) -> (Option<usize>, Option<usize>)

Source§

fn finish(self, pushed: usize) -> Result<Self::Output, Self>

Source§

impl<T> Storage<T> for &mut Vec<T>

Source§

type Output = usize

Source§

fn reserve(&mut self, len: usize)

Source§

fn insert(&mut self, _index: usize, item: T)

Source§

fn finish(self, pushed: usize) -> Result<Self::Output, Self>

Source§

impl<T> Storage<T> for Option<T>

Source§

type Output = T

Source§

fn insert(&mut self, _index: usize, item: T)

Source§

fn bounds(&self) -> (Option<usize>, Option<usize>)

Source§

fn finish(self, _pushed: usize) -> Result<Self::Output, Self>

Implementors§