#message #reply #async

async-reply

Library to handle typed messages and replies

4 releases

0.2.2 Mar 21, 2022
0.2.1 May 29, 2021
0.2.0 Jan 6, 2021
0.1.0 Dec 22, 2020

#1 in #reply

MIT/Apache

15KB
114 lines

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.

Dependencies

~6–17MB
~221K SLoC