Expand description
Utilities for forwarding the result of a future to another future
The forwarder function creates a pair of Sender and Receiver that
can be used to forward the result of a future to another future. The sender
half is used to send the result, and the receiver half is used to receive the
result.
let (sender, receiver) = forwarder::<u32>();
// The result is not yet available
assert_eq!(receiver.try_receive(), Err(TryReceiveError::NotSent));
// Send the result
sender.send(42).unwrap();
// The result is now available
assert_eq!(receiver.try_receive(), Ok(42));If the Sender is dropped before sending the result, the Receiver will
never receive the result. If the Receiver is dropped before receiving the
result, the Sender will not be able to send the result, but it does not
otherwise affect the task that produces the result.
Structs§
Enums§
- TryReceive
Error - Error returned when receiving a value fails
Functions§
- forwarder
- Creates a new forwarder.