Trait Client

Source
pub trait Client<'a, Req> {
    type Response;
    type Future: Future<Output = Result<Self::Response>> + 'a;

    // Required method
    fn call(&'a mut self, ctx: Context, request: Req) -> Self::Future;

    // Provided methods
    fn map_response<F, R>(self, f: F) -> MapResponse<Self, F>
       where F: FnMut(Self::Response) -> R,
             Self: Sized { ... }
    fn with_request<F, Req2>(self, f: F) -> WithRequest<Self, F>
       where F: FnMut(Req2) -> Req,
             Self: Sized { ... }
}
Expand description

Sends multiplexed requests to, and receives responses from, a server.

Required Associated Types§

Source

type Response

The response type.

Source

type Future: Future<Output = Result<Self::Response>> + 'a

The future response.

Required Methods§

Source

fn call(&'a mut self, ctx: Context, request: Req) -> Self::Future

Initiates a request, sending it to the dispatch task.

Returns a Future that resolves to this client and the future response once the request is successfully enqueued.

Provided Methods§

Source

fn map_response<F, R>(self, f: F) -> MapResponse<Self, F>
where F: FnMut(Self::Response) -> R, Self: Sized,

Returns a Client that applies a post-processing function to the returned response.

Source

fn with_request<F, Req2>(self, f: F) -> WithRequest<Self, F>
where F: FnMut(Req2) -> Req, Self: Sized,

Returns a Client that applies a pre-processing function to the request.

Implementors§

Source§

impl<'a, C, F, Req, Req2, Resp> Client<'a, Req2> for WithRequest<C, F>
where C: Client<'a, Req, Response = Resp>, F: FnMut(Req2) -> Req,

Source§

type Response = Resp

Source§

type Future = <C as Client<'a, Req>>::Future

Source§

impl<'a, C, F, Req, Resp, Resp2> Client<'a, Req> for MapResponse<C, F>
where C: Client<'a, Req, Response = Resp>, F: FnMut(Resp) -> Resp2 + 'a,

Source§

type Response = Resp2

Source§

type Future = MapOk<<C as Client<'a, Req>>::Future, &'a mut F>

Source§

impl<'a, Req, Resp> Client<'a, Req> for Channel<Req, Resp>
where Req: 'a, Resp: 'a,

Source§

type Response = Resp

Source§

type Future = Call<'a, Req, Resp>