Skip to main content

GrpcService

Trait GrpcService 

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

    // Required method
    fn serve(
        &self,
        request: Request<ReqBody>,
    ) -> impl Future<Output = Result<Response<Self::ResponseBody>, Self::Error>> + Send;
}
Available on crate features http and grpc only.
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 + Send + Sync>>

Errors produced by the service.

Required Methods§

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

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 + Send + Sync>>, ResBody: Body, <ResBody as Body>::Error: Into<Box<dyn Error + Send + Sync>>,

§

type ResponseBody = ResBody

§

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