Crate bidirectional_channel[][src]

Expand description

An async channel with request-response semantics.
When a Responder is asked to receive a request, it returns a ReceivedRequest, which should be used to communicate back to the sender

use bidirectional_channel::{bounded};
let (requester, responder) = bounded(1);
let requester = async { requester.send("hello").await.unwrap() };
let responder = async {
    let request = responder.recv().await.unwrap();
    let len = request.len();
let (response, request) = join!(requester, responder);
assert!(request.len() == response)


Represents the request. This implements AsRef and AsMut for the request itself for explicit use. Alternatively, you may use Deref and DerefMut either explicitly, or coerced. Must be used by calling ReceivedRequest::respond, or destructured.

Represents the initiator for the request-response exchange

An async_std::channel::Receiver which receives an UnRespondedRequest<Req, Resp> instead of a Req.

Represents that the Requester associated with this communication is still waiting for a response.


Error returned when sending a request


Create a bounded Requester-Responder pair.
That is, once the channel is full, future senders will yield when awaiting until there’s space again