pub trait HyperService {
    fn handle(
        &self,
        req: Request<Body>
    ) -> Pin<Box<dyn Future<Output = Result<Response<Body>, ProstTwirpError>> + Send>>; }
Expand description

A trait for the heart of a Twirp service: responding to every service method.

Implementations are responsible for:

  1. Matching the URL to a service method (or returning a 404).
  2. Decoding the request body into a protobuf message, typically using ServiceRequest::from_hyper_request for the appropriate message.
  3. Calling the application logic to handle the request.
  4. Encoding the response into a protobuf message, typically using ServiceResponse::to_hyper_response.

An implementation of this trait is generated by the service-gen integration, or it can be implemented manually.

Required Methods§

Accept a raw service request and return a boxed future of a raw service response

Implementors§