[][src]Crate 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;

Structs

ReplyHandle

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.

Functions

endpoints

Create a Requester and Replyer message endpoints which allow the sending and receiving of typed messages.