pub fn channel<T>(
name: &str,
data_dir: &Path,
) -> Result<(Sender<T>, Receiver<T>), Error>where
T: Serialize + DeserializeOwned,Expand description
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 maximum number of bytes that will
be stored in-memory is 1Mb and the maximum size of a queue file will be
100Mb. 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());