Struct Sender

pub struct Sender<T> { /* private fields */ }

A means of transmitting a single value to another task.

This is created by the channel function.

Implementations

impl<T> Sender<T>

fn send(self, t: T) -> Result<(), T>

Completes this oneshot with a successful result.

This function will consume self and indicate to the other end, the Receiver, that the value provided is the result of the computation this represents.

If the value is successfully enqueued for the remote end to receive, then Ok(()) is returned. If the receiving end was dropped before this function was called, however, then Err(t) is returned.

fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()>

Polls this Sender half to detect whether its associated Receiver has been dropped.

Return values

If Ready(()) is returned then the associated Receiver has been dropped, which means any work required for sending should be canceled.

If Pending is returned then the associated Receiver is still alive and may be able to receive a message if sent. The current task, however, is scheduled to receive a notification if the corresponding Receiver goes away.

fn cancellation(&mut self) -> Cancellation<'_, T>

Creates a future that resolves when this Sender's corresponding Receiver half has hung up.

This is a utility wrapping poll_canceled to expose a Future.

fn is_canceled(&self) -> bool

Tests to see whether this Sender's corresponding Receiver has been dropped.

Unlike poll_canceled, this function does not enqueue a task for wakeup upon cancellation, but merely reports the current state, which may be subject to concurrent modification.

fn is_connected_to(&self, receiver: &Receiver<T>) -> bool

Tests to see whether this Sender is connected to the given Receiver. That is, whether they were created by the same call to channel.

Trait Implementations

impl<T> Debug for Sender<T>

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

impl<T> Drop for Sender<T>

fn drop(&mut self)

impl<T> Unpin for Sender<T>

Auto Trait Implementations

impl<T> !RefUnwindSafe for Sender<T>

impl<T> !UnwindSafe for Sender<T>

impl<T> Freeze for Sender<T> where Arc<Inner<T>>: Freeze,

impl<T> Send for Sender<T> where Arc<Inner<T>>: Send,

impl<T> Sync for Sender<T> where Arc<Inner<T>>: Sync,

impl<T> UnsafeUnpin for Sender<T> where Arc<Inner<T>>: UnsafeUnpin,

Blanket Implementations

impl<T> Any for Sender<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Sender<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Sender<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Sender<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for Sender<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Sender<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Sender<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>