messenger

Crates.iomessenger
lib.rsmessenger
version0.1.0
sourcesrc
created_at2018-02-27 17:21:37.541709
updated_at2018-02-27 17:21:37.541709
descriptiontwo way messenger
homepagehttps://gitlab.com/nathanfaucett/rs-messenger
repositoryhttps://gitlab.com/nathanfaucett/rs-messenger.git
max_upload_size
id53066
size16,022
Nathan Faucett (nathanfaucett)

documentation

README

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);
    });
}

Commit count: 6

cargo fmt