async-reply

Crates.ioasync-reply
lib.rsasync-reply
version0.2.2
sourcesrc
created_at2020-12-22 20:10:43.258141
updated_at2022-03-21 13:49:12.492681
descriptionLibrary to handle typed messages and replies
homepagehttps://github.com/OSSystems/async-reply-rs
repositoryhttps://github.com/OSSystems/async-reply-rs
max_upload_size
id326172
size43,763
Otavio Salvador (otavio)

documentation

https://docs.rs/async-reply

README

Documentation CI (Linux)

async-reply

Allow the sending and reciving of typed messages.

Example

use async_reply::Message;

#[derive(Debug, Message)]
#[rtype(response = "Pong")]
struct Ping;

#[derive(Debug)]
struct Pong;

let (requester, replyer) = async_reply::endpoints();

let ping_fut = async {
    println!("Sending Ping");
    let reply = requester.send(Ping).await.unwrap();
    println!("Received {:?}", reply);
};

let pong_fut = async {
    let (msg, handler) = replyer.recv::<Ping>().await.unwrap();
    handler.respond(Pong).await.unwrap();
    println!("Replied {:?} with Pong", msg);
};

ping_fut.join(pong_fut).await;

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 32

cargo fmt