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::Respond; // Don't forget to import this trait let (requester, responder) = bidirectional_channel::bounded(10); let future_response = requester.send(String::from("hello")).await.unwrap(); // This side of the channel receives Strings, and responds with their length let received_request = responder.recv().await.unwrap(); let len = received_request.len(); // Deref coercion to the actual request received_request.respond(len).unwrap(); assert!(future_response.await.unwrap() == 5);
Structs
ReceivedRequest | Represents the request.
This implements |
Requester | Represents the initiator for the request-response exchange |
Responder | The receiving side of a channel. |
UnRespondedRequest | Represents that the |
Traits
Respond | Represents fullfilling a |
Functions
bounded | Create a bounded |
Type Definitions
FutureResponse | Represents waiting for the |