Module oneshot
A one-shot channel is used for sending a single message between
asynchronous tasks. The channel function is used to create a
Sender and Receiver handle pair that form the channel.
The Sender handle is used by the producer to send the value.
The Receiver handle is used by the consumer to receive the value.
Each handle can be used on separate tasks.
Since the send method is not async, it can be used anywhere. This includes
sending between two runtimes, and using it from non-async code.
If the Receiver is closed before receiving a message which has already
been sent, the message will remain in the channel until the receiver is
dropped, at which point the message will be dropped immediately.
Examples
use oneshot;
async
If the sender is dropped without sending, the receiver will fail with
[error::RecvError]:
use oneshot;
async
To use a oneshot channel in a tokio::select! loop, add &mut in front of
the channel.
use oneshot;
use ;
# async
#
async
To use a Sender from a destructor, put it in an Option and call
Option::take.
use oneshot;
# async
#
async
Modules
-
error
Oneshoterror types.
Structs
Functions
- channel Creates a new one-shot channel for sending single values across asynchronous tasks.