[][src]Trait hyper::service::Service

pub trait Service {
    type ReqBody: Payload;
    type ResBody: Payload;
    type Error: Into<Box<dyn StdError + Send + Sync>>;
    type Future: Future<Item = Response<Self::ResBody>, Error = Self::Error>;
    fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future;

    fn poll_ready(&mut self) -> Poll<(), Self::Error> { ... }
}

An asynchronous function from Request to Response.

Associated Types

type ReqBody: Payload

The Payload body of the http::Request.

type ResBody: Payload

The Payload body of the http::Response.

type Error: Into<Box<dyn StdError + Send + Sync>>

The error type that can occur within this Service.

Note: Returning an Error to a hyper server will cause the connection to be abruptly aborted. In most cases, it is better to return a Response with a 4xx or 5xx status code.

type Future: Future<Item = Response<Self::ResBody>, Error = Self::Error>

The Future returned by this Service.

Loading content...

Required methods

fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future

Calls this Service with a request, returning a Future of the response.

Loading content...

Provided methods

fn poll_ready(&mut self) -> Poll<(), Self::Error>

Returns Ready when the service is able to process requests.

The implementation of this method is allowed to return a Ready even if the service is not ready to process. In this case, the future returned from call will resolve to an error.

Loading content...

Implementors

Loading content...