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§
- Received
Request - Represents the request.
This implements
AsRefandAsMutfor the request itself for explicit use. Alternatively, you may useDerefandDerefMuteither explicitly, or coerced. Must be used by callingReceivedRequest::respond, or destructured. - Requester
- Represents the initiator for the request-response exchange
- Responder
- An
async_std::channel::Receiverwhich receives anUnRespondedRequest<Req, Resp>instead of aReq. The receiving side of a channel. - UnResponded
Request - Represents that the
Requesterassociated with this communication is still waiting for a response.
Enums§
- Send
Request Error - Error returned when sending a request