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
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(&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(&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) -> 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, receiver: &Receiver<T>) -> boolTests to see whether this
Senderis connected to the givenReceiver. That is, whether they were created by the same call tochannel.
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) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Sender<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>