[][src]Struct edelcrantz::Connection

pub struct Connection<OneWay: Msg, Request: Msg, Response: Msg> { /* fields omitted */ }

Implementations

impl<OneWay: Msg, Request: Msg, Response: Msg> Connection<OneWay, Request, Response>[src]

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.

pub fn new<RW: AsyncReadWrite>(rw: RW) -> Self[src]

pub fn enqueue_oneway(&mut self, oneway: OneWay) -> Result<(), Error>[src]

Enqueue a OneWay message for sending.

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

Enqueue a Request message for sending, and return a future that will be filled in when the response arrives.

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), 
[src]

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> !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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.