[][src]Trait async_svc::Svc

pub trait Svc<Req> {
    type Res;
    type Fut: Future<Output = Self::Res>;
    pub fn exec(self: Pin<&mut Self>, req: Req) -> Self::Fut;

    pub fn poll_ready(self: Pin<&mut Self>, cx: Context<'_>) -> Poll<()> { ... }
}

Service trait representing an asynchronous request/response operation.

Associated Types

type Res

Output type.

type Fut: Future<Output = Self::Res>

Response future.

Loading content...

Required methods

pub fn exec(self: Pin<&mut Self>, req: Req) -> Self::Fut

Processes request, producing a future that outputs the response type.

Loading content...

Provided methods

pub fn poll_ready(self: Pin<&mut Self>, cx: Context<'_>) -> Poll<()>

To be called before exec to signal wether the service is ready to process requests. As such, the check should be inexpensive. Returning Poll::Pending acts as back-pressure. The default implementation unconditionally indicates the service is ready.

Loading content...

Implementations on Foreign Types

impl<S, Req> Svc<Req> for Box<S> where
    S: Svc<Req>, 
[src]

type Res = S::Res

type Fut = S::Fut

Loading content...

Implementors

impl<F, Req, Fut, Res> Svc<Req> for FnSvc<F> where
    F: FnMut(Req) -> Fut + Unpin,
    Fut: Future<Output = Res>, 
[src]

type Res = Res

type Fut = Fut

impl<Req, Res> Svc<Req> for BoxSvc<Req, Res>[src]

type Res = Res

type Fut = BoxFut<Res>

impl<S1, S2, Req, Int, Res> Svc<Req> for ThenSvc<S1, S2, Int, Res> where
    S1: Svc<Req, Res = Int>,
    S2: Svc<Int, Res = Res>, 
[src]

type Res = Res

type Fut = ThenSvcFut<S1, S2, Req, Int, Res>

impl<S, Req, F, Res> Svc<Req> for MapSvc<S, F, Res> where
    S: Svc<Req>,
    F: FnMut(S::Res) -> Res + Clone
[src]

type Res = Res

type Fut = MapSvcFut<S, F, Req, Res>

Loading content...