Struct Sender
struct Sender<T> { ... }
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: Self, t: T) -> Result<(), T>Completes this oneshot with a successful result.
This function will consume
selfand indicate to the other end, theReceiver, 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, thenErr(t)is returned.fn poll_canceled(self: &mut Self, cx: &mut Context<'_>) -> Poll<()>Polls this
Senderhalf to detect whether its associatedReceiverhas been dropped.Return values
If
Ready(())is returned then the associatedReceiverhas been dropped, which means any work required for sending should be canceled.If
Pendingis returned then the associatedReceiveris still alive and may be able to receive a message if sent. The current task, however, is scheduled to receive a notification if the correspondingReceivergoes away.fn cancellation(self: &mut Self) -> Cancellation<'_, T>Creates a future that resolves when this
Sender's correspondingReceiverhalf has hung up.This is a utility wrapping
poll_canceledto expose aFuture.fn is_canceled(self: &Self) -> boolTests to see whether this
Sender's correspondingReceiverhas 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: &Self, receiver: &Receiver<T>) -> boolTests to see whether this
Senderis connected to the givenReceiver. That is, whether they were created by the same call tochannel.
impl<T> Any for Sender<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Sender<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Sender<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> Debug for Sender<T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T> Drop for Sender<T>
fn drop(self: &mut Self)
impl<T> Freeze for Sender<T>
impl<T> From for Sender<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>
impl<T> Sync for Sender<T>
impl<T> Unpin for Sender<T>
impl<T> UnsafeUnpin for Sender<T>
impl<T> UnwindSafe for Sender<T>
impl<T, U> Into for Sender<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Sender<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Sender<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>