Trait GrpcService

Source
pub trait GrpcService<ReqBody> {
    type ResponseBody: Body + HttpBody;
    type Future: Future<Item = Response<Self::ResponseBody>, Error = Self::Error>;
    type Error: Into<Box<dyn Error + Send + Sync>>;

    // Required methods
    fn poll_ready(&mut self) -> Poll<(), Self::Error>;
    fn call(&mut self, request: Request<ReqBody>) -> Self::Future;

    // Provided methods
    fn into_service(self) -> IntoService<Self>
       where Self: Sized { ... }
    fn as_service(&mut self) -> AsService<'_, Self>
       where Self: Sized { ... }
}
Expand description

A specialization of tower_service::Service.

Existing tower_service::Service implementations with the correct form will automatically implement GrpcService.

Required Associated Types§

Source

type ResponseBody: Body + HttpBody

Response body type

Source

type Future: Future<Item = Response<Self::ResponseBody>, Error = Self::Error>

Response future

Source

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

Error type

Required Methods§

Source

fn poll_ready(&mut self) -> Poll<(), Self::Error>

Poll that this service is ready.

Source

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

Call the service.

Provided Methods§

Source

fn into_service(self) -> IntoService<Self>
where Self: Sized,

Helper when needing to pass this type to bounds needing Service.

Source

fn as_service(&mut self) -> AsService<'_, Self>
where Self: Sized,

Helper when needing to pass this type to bounds needing Service.

Implementors§

Source§

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

Source§

type ResponseBody = ResBody

Source§

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

Source§

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