Module nbchan::oneshot [−][src]
Oneshot channel.
The sender of a oneshot channel can send at most one message to the corresponding receiver.
Examples
use std::thread; use nbchan::oneshot::{self, TryRecvError}; let (tx, mut rx) = oneshot::channel(); // Sender thread::spawn(|| { tx.send(10).unwrap(); }); // Receiver loop { match rx.try_recv() { Ok(v) => { assert_eq!(v, 10); break; } Err(e) => { assert_eq!(e, TryRecvError::Empty); } } }
Re-exports
pub use std::sync::mpsc::SendError; |
pub use std::sync::mpsc::TryRecvError; |
Structs
Receiver |
The receiving-half of an asynchronous oneshot channel. |
Sender |
The sending-half of an asynchronous oneshot channel. |
Functions
channel |
Creates a new asynchronous oneshot channel, returning the sender/receiver halves. |