pub trait Service<Request> {
    type Response;
    type Error;
    type Future: Future<Item = Self::Response, Error = Self::Error>;

    fn poll_ready(&mut self) -> Poll<(), Self::Error>;
    fn call(&mut self, req: Request) -> Self::Future;
}
Expand description

An asynchronous function from Request to a Response.

Required Associated Types§

Responses given by the service.

Errors produced by the service.

The future response value.

Required Methods§

Returns Ready when the service is able to process requests.

If the service is at capacity, then NotReady is returned and the task is notified when the service becomes ready again. This function is expected to be called while on a task.

This is a best effort implementation. False positives are permitted. It is permitted for the service to return Ready from a poll_ready call and the next invocation of call results in an error.

Process the request and return the response asynchronously.

This function is expected to be callable off task. As such, implementations should take care to not call poll_ready. If the service is at capacity and the request is unable to be handled, the returned Future should resolve to an error.

Calling call without calling poll_ready is permitted. The implementation must be resilient to this fact.

Implementations on Foreign Types§

Implementors§