Connection

Struct Connection 

Source
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.

Source

pub fn new_split<R, W>(rdr: R, wtr: W) -> Self
where R: AsyncRead + Unpin + Send + Sync + 'static, W: AsyncWrite + Unpin + Send + Sync + 'static,

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).

Source

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.

Source

pub fn enqueue_oneway( &self, oneway: OneWay, ) -> impl Future<Output = Result<(), Error>> + 'static

Just calls self.queue.enqueue_oneway.

Source

pub fn enqueue_request( &self, req: Request, ) -> impl Future<Output = Result<Response, Error>> + 'static

Just calls self.queue.enqueue_request.

Source

pub async fn advance<ServeRequest, FutureResponse, ServeOneWay>( &mut self, srv_req: ServeRequest, srv_ow: ServeOneWay, ) -> Result<(), Error>
where ServeRequest: FnOnce(Request) -> FutureResponse, FutureResponse: Future<Output = Response> + Send + 'static, ServeOneWay: FnOnce(OneWay),

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.

Auto Trait Implementations§

§

impl<OneWay, Request, Response> !Freeze for Connection<OneWay, Request, Response>

§

impl<OneWay, Request, Response> !RefUnwindSafe for Connection<OneWay, Request, Response>

§

impl<OneWay, Request, Response> Send for Connection<OneWay, Request, Response>

§

impl<OneWay, Request, Response> !Sync for Connection<OneWay, Request, Response>

§

impl<OneWay, Request, Response> Unpin for Connection<OneWay, Request, Response>

§

impl<OneWay, Request, Response> !UnwindSafe for Connection<OneWay, Request, Response>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more