Crate async_reply
source · [−]Expand description
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;
Structs
The reply handle to respond to the received message.
The replyer side of a endpoint.
The requester side of a endpoint.
Enums
Encapsulate the errors which can be triggered when sending or receiving a message.
Traits
A trait to bind the message and its respective response type.