Trait hyper::service::Service

source ·
pub trait Service<Request> {
    type Response;
    type Error;
    type Future: Future<Output = Result<Self::Response, Self::Error>>;

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

An asynchronous function from a Request to a Response.

The Service trait is a simplified interface making it easy to write network applications in a modular and reusable way, decoupled from the underlying protocol.

Functional

A Service is a function of a Request. It immediately returns a Future representing the eventual completion of processing the request. The actual request processing may happen at any time in the future, on any thread or executor. The processing may depend on calling other services. At some point in the future, the processing will complete, and the Future will resolve to a response or error.

At a high level, the Service::call function represents an RPC request. The Service value can be a server or a client.

Required Associated Types§

Responses given by the service.

Errors produced by the service.

The future response value.

Required Methods§

Process the request and return the response asynchronously.

Implementors§