Function hopper::channel
[−]
[src]
pub fn channel<T>(name: &str,
data_dir: &Path)
-> Result<(Sender<T>, Receiver<T>), Error> where T: Serialize + Deserialize
Create a (Sender, Reciever) pair in a like fashion to
std::sync::mpsc::channel
This function creates a Sender and Receiver pair with name name
whose
queue files are stored in data_dir
. The Sender is clonable.
Example
extern crate tempdir; extern crate hopper; let dir = tempdir::TempDir::new("hopper").unwrap(); let (mut snd, mut rcv) = hopper::channel("example", dir.path()).unwrap(); snd.send(9); assert_eq!(Some(9), rcv.iter().next());