pub struct Connection<OneWay: Msg, Request: Msg, Response: Msg> {
pub queue: Queue<OneWay, Request, Response>,
/* private fields */
}Fields§
§queue: Queue<OneWay, Request, Response>A queue that can be cloned out of the Connection and used to submit work without having exclusive ownership of the Connection.
Implementations§
Source§impl<OneWay: Msg, Request: Msg, Response: Msg> Connection<OneWay, Request, Response>
A connection encapsulates logic for sending and receiving a particular
vocabulary of messages: one-way messages, requests, and responses. The
message types may be different or all the same, and may have internal
structure or be enums that have further meaning to the caller: all the
connection knows is that messages of the request type will be responded-to
by messages of the response type, and messages of the one-way type will not
be responded to.
impl<OneWay: Msg, Request: Msg, Response: Msg> Connection<OneWay, Request, Response>
A connection encapsulates logic for sending and receiving a particular vocabulary of messages: one-way messages, requests, and responses. The message types may be different or all the same, and may have internal structure or be enums that have further meaning to the caller: all the connection knows is that messages of the request type will be responded-to by messages of the response type, and messages of the one-way type will not be responded to.
Sourcepub fn new_split<R, W>(rdr: R, wtr: W) -> Self
pub fn new_split<R, W>(rdr: R, wtr: W) -> Self
Construct a new Connection from a separate AsyncRead and AsyncWrite pair;
in some cases this will perform better than passing a merged AsyncRead+AsyncWrite
and having it split (which we do in new below).
Sourcepub fn new<RW: AsyncReadWrite>(rw: RW) -> Self
pub fn new<RW: AsyncReadWrite>(rw: RW) -> Self
Construct a new Connection from an AsyncRead+AsyncWrite value, splitting
it and passing the read and write parts to new_split.
Sourcepub fn enqueue_oneway(
&self,
oneway: OneWay,
) -> impl Future<Output = Result<(), Error>> + 'static
pub fn enqueue_oneway( &self, oneway: OneWay, ) -> impl Future<Output = Result<(), Error>> + 'static
Just calls self.queue.enqueue_oneway.
Sourcepub fn enqueue_request(
&self,
req: Request,
) -> impl Future<Output = Result<Response, Error>> + 'static
pub fn enqueue_request( &self, req: Request, ) -> impl Future<Output = Result<Response, Error>> + 'static
Just calls self.queue.enqueue_request.
Sourcepub async fn advance<ServeRequest, FutureResponse, ServeOneWay>(
&mut self,
srv_req: ServeRequest,
srv_ow: ServeOneWay,
) -> Result<(), Error>
pub async fn advance<ServeRequest, FutureResponse, ServeOneWay>( &mut self, srv_req: ServeRequest, srv_ow: ServeOneWay, ) -> Result<(), Error>
Take the next available step on this connection. Either:
- Sending an enqueued envelope.
- Resolving and enqueueing the output of a request’s service routine future.
- Receiving an envelope and transferring it to either a service routine or a response future created by Connection::enqueue_request.
Callers should supply a srv_req function to service request envelopes
by issuing futures, and a srv_ow function to service one-way
envelopes.