Sender

Struct Sender 

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

The sending end of this batching queue

Since this is a single-producer queue, this handle cannot be cloned or shared. Dropping this handle will eventually lead to the receiver signaling that this queue has been closed.

Implementations§

Source§

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

Source

pub fn try_send(&mut self, value: T) -> Result<bool, TrySendError<T>>

Try sending a value via the queue

This may return TrySendError::Closed in case the receiver has been dropped (see send). Or it may return TrySendError::Full() to hand you back the value in case it can currently not be accepted because the queue is full.

Source

pub fn close_batch(&mut self)

Hand the current bucket over to the receiver, even if it is not full

This is a no-op if the current bucket is empty.

Source

pub fn send(&mut self, value: T) -> SendFuture<'_, T, N>

A future that will eventually send the value

If the channel is or has been closed, the value is dropped, just as the values that are in the queue when both ends are dropped.

The sent value will not be visible to the receiver until the current bucket is handed over, which happens either when the bucket is full or close_batch is called.

Trait Implementations§

Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T, const N: usize> !UnwindSafe for Sender<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.