Receiver

Struct Receiver 

Source
pub struct Receiver<T, const N: usize> { /* private fields */ }
Expand description

The receiving end of this batching queue

Since this is a single-consume queue, this handle cannot be cloned or shared. Dropping this handle will eventually lead to the sender signaling that this queue has been closed. Items that were in flight will be dropped.

Implementations§

Source§

impl<T, const N: usize> Receiver<T, N>

Source

pub fn try_recv_batch(&mut self) -> Result<Vec<T>, TryRecvError>

Check if a batch is currently available and fill them into a fresh Vec

If no batch is available it returns TryRecvError::Empty. If no batch will ever become available because the sender has been dropped it returns TryRecvError::Closed.

If the next thing you’ll do is to iterate over the vector, prefer try_recv instead to save one allocation.

Source

pub fn try_recv(&mut self) -> Result<BucketIter<'_, T, N>, TryRecvError>

Check if a batch is currently available and return an iterator of its items

If no batch is available it returns TryRecvError::Empty. If no batch will ever become available because the sender has been dropped it returns TryRecvError::Closed.

See recv for more information on the returned iterator.

Source

pub fn recv(&mut self) -> ReceiveFuture<'_, T, N>

A Future that will wait for the next batch and return an iterator of its items

The iterator should be consumed quickly since it borrows the queue bucket that holds the items, meaning that the queue space is not handed back to the sender until the iterator is dropped.

Source

pub async fn recv_batch(&mut self) -> Result<Vec<T>, Closed>

Wait for the next batch and fill it into a fresh Vec

If the next thing you’ll do is to iterate over the vector, prefer recv instead to save one allocation.

Trait Implementations§

Source§

impl<T, const N: usize> Drop for Receiver<T, N>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, const N: usize> Send for Receiver<T, N>

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for Receiver<T, N>

§

impl<T, const N: usize> !RefUnwindSafe for Receiver<T, N>

§

impl<T, const N: usize> !Sync for Receiver<T, N>

§

impl<T, const N: usize> Unpin for Receiver<T, N>

§

impl<T, const N: usize> !UnwindSafe for Receiver<T, N>

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.