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();
request.respond(len).unwrap()
};
let (response, request) = join!(requester, responder);
assert!(request.len() == response)
Structs§
- Represents the request. This implements
AsRef
andAsMut
for the request itself for explicit use. Alternatively, you may useDeref
andDerefMut
either explicitly, or coerced. Must be used by callingReceivedRequest::respond
, or destructured. - Represents the initiator for the request-response exchange
- An
async_std::channel::Receiver
which receives anUnRespondedRequest<Req, Resp>
instead of aReq
. The receiving side of a channel. - Represents that the
Requester
associated with this communication is still waiting for a response.
Enums§
- Error returned when sending a request