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

pub trait Service<ReqBody>: Sealed<ReqBody> {
    type ResBody: Payload;
    type Error: Into<Box<dyn StdError + Send + Sync>>;
    type Future: Future<Output = Result<Response<Self::ResBody>, Self::Error>>;
    fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>>;
fn call(&mut self, req: Request<ReqBody>) -> Self::Future; }

An asynchronous function from Request to Response.

Associated Types

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<Output = Result<Response<Self::ResBody>, Self::Error>>

The Future returned by this Service.

Loading content...

Required methods

fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), 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.

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

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

Loading content...

Implementors

impl<T, B1, B2> Service<B1> for T where
    T: Service<Request<B1>, Response = Response<B2>>,
    B2: Payload,
    T::Error: Into<Box<dyn StdError + Send + Sync>>, 
[src]

type ResBody = B2

type Error = T::Error

type Future = T::Future

Loading content...