1 unstable release
Uses old Rust 2015
0.1.0 | Feb 27, 2018 |
---|
#6 in #unbounded
24 downloads per month
Used in 2 crates
(via virtual_view)
14KB
382 lines
rs-messenger
two way messenger
extern crate messenger;
extern crate tokio;
use messenger::unbounded_channel;
use tokio::executor::current_thread;
fn main() {
let (ping, pong, future) = unbounded_channel();
let _ = ping.on("message", |m| {
println!("Ping received {:?}", m);
Some("Pong".to_owned())
});
let p = pong.clone();
let _ = pong.send("message", "Pong".to_owned(), move |data| {
println!("Pong callback {:?}", data);
p.close();
});
current_thread::run(move |_| {
let _ = current_thread::spawn(future);
});
}
Dependencies
~0.4–1MB
~22K SLoC