From 5758b758b2d44059b0149a31542d11589999a789 Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Sat, 28 Mar 2020 17:52:10 +0100 Subject: [PATCH] fix(build): Server service uses generic body bound (#306) Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- tonic-build/src/server.rs | 9 +++++++-- tonic/src/codegen.rs | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tonic-build/src/server.rs b/tonic-build/src/server.rs index 105494321..b9e687b61 100644 --- a/tonic-build/src/server.rs +++ b/tonic-build/src/server.rs @@ -49,7 +49,12 @@ pub fn generate<'a, T: Service<'a>>(service: &'a T, context: &T::Context) -> Tok } } - impl Service> for #server_service { + impl Service> for #server_service + where + T: #server_trait, + B: HttpBody + Send + Sync + 'static, + B::Error: Into + Send + 'static, + { type Response = http::Response; type Error = Never; type Future = BoxFuture; @@ -58,7 +63,7 @@ pub fn generate<'a, T: Service<'a>>(service: &'a T, context: &T::Context) -> Tok Poll::Ready(Ok(())) } - fn call(&mut self, req: http::Request) -> Self::Future { + fn call(&mut self, req: http::Request) -> Self::Future { let inner = self.inner.clone(); match req.uri().path() { diff --git a/tonic/src/codegen.rs b/tonic/src/codegen.rs index e5eea9b91..4f0509ad0 100644 --- a/tonic/src/codegen.rs +++ b/tonic/src/codegen.rs @@ -13,9 +13,6 @@ pub use tower_service::Service; pub type StdError = Box; pub use crate::body::Body; -#[cfg(feature = "transport")] -pub use hyper::Body as HyperBody; - pub type BoxFuture = self::Pin> + Send + 'static>>; pub type BoxStream = self::Pin> + Send + 'static>>;