pub struct Sender<T>(/* private fields */);
Expand description
Sends a value to the associated Receiver
.
A pair of both a Sender
and a Receiver
are created by the
channel
function.
If the sender is dropped without sending, the receiver will fail with
super::RecvError
Implementations§
source§impl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn send(self, value: T) -> Result<(), T>
pub fn send(self, value: T) -> Result<(), T>
Attempts to send a value on this channel, returning it back if it could not be sent.
This method consumes self
as only one value may ever be sent on a oneshot
channel. It is not marked async because sending a message to an oneshot
channel never requires any form of waiting. Because of this, the send
method can be used in both synchronous and asynchronous code without
problems.
A successful send occurs when it is determined that the other end of the
channel has not hung up already. An unsuccessful send would be one where
the corresponding receiver has already been deallocated. Note that a
return value of Err
means that the data will never be received, but
a return value of Ok
does not mean that the data will be received.
It is possible for the corresponding receiver to hang up immediately
after this function returns Ok
.