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§
- Reply
Handle - The reply handle to respond to the received message.
- Replyer
- The replyer side of a endpoint.
- Requester
- The requester side of a endpoint.
Enums§
- Error
- Encapsulate the errors which can be triggered when sending or receiving a message.
Traits§
- Message
- A trait to bind the message and its respective response type.