GrpcService

Trait GrpcService 

pub trait GrpcService<ReqBody>:
    Send
    + Sync
    + 'static {
    type ResponseBody: Body;
    type Error: Into<Box<dyn Error + Sync + Send>>;

    // Required method
    fn serve(
        &self,
        request: Request<ReqBody>,
    ) -> impl Future<Output = Result<Response<Self::ResponseBody>, Self::Error>>;
}
Expand description

Definition of the gRPC trait alias for Service.

This trait enforces that all rama services provided to Grpc implements the correct traits.

Required Associated Types§

type ResponseBody: Body

Responses body given by the service.

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

Errors produced by the service.

Required Methods§

fn serve( &self, request: Request<ReqBody>, ) -> impl Future<Output = Result<Response<Self::ResponseBody>, Self::Error>>

Process the request and return the response asynchronously.

Reference Service::serve.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<T, ReqBody, ResBody> GrpcService<ReqBody> for T
where T: Service<Request<ReqBody>, Output = Response<ResBody>>, <T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Sync + Send>>, ResBody: Body, <ResBody as Body>::Error: Into<Box<dyn Error + Sync + Send>>,

§

type ResponseBody = ResBody

§

type Error = <T as Service<Request<ReqBody>>>::Error