diff --git a/tonic/src/body.rs b/tonic/src/body.rs index e5220f9f1..5e5ba2c54 100644 --- a/tonic/src/body.rs +++ b/tonic/src/body.rs @@ -9,7 +9,7 @@ pub type BoxBody = http_body_util::combinators::UnsyncBoxBody(body: B) -> BoxBody where B: http_body::Body + Send + 'static, - B::Error: Into, + B::Error: Into, { body.map_err(crate::Status::map_error).boxed_unsync() } diff --git a/tonic/src/client/grpc.rs b/tonic/src/client/grpc.rs index ba4c84669..10fa87867 100644 --- a/tonic/src/client/grpc.rs +++ b/tonic/src/client/grpc.rs @@ -213,7 +213,7 @@ impl Grpc { where T: GrpcService, T::ResponseBody: Body + Send + 'static, - ::Error: Into, + ::Error: Into, C: Codec, M1: Send + Sync + 'static, M2: Send + Sync + 'static, @@ -232,7 +232,7 @@ impl Grpc { where T: GrpcService, T::ResponseBody: Body + Send + 'static, - ::Error: Into, + ::Error: Into, S: Stream + Send + 'static, C: Codec, M1: Send + Sync + 'static, @@ -269,7 +269,7 @@ impl Grpc { where T: GrpcService, T::ResponseBody: Body + Send + 'static, - ::Error: Into, + ::Error: Into, C: Codec, M1: Send + Sync + 'static, M2: Send + Sync + 'static, @@ -288,7 +288,7 @@ impl Grpc { where T: GrpcService, T::ResponseBody: Body + Send + 'static, - ::Error: Into, + ::Error: Into, S: Stream + Send + 'static, C: Codec, M1: Send + Sync + 'static, @@ -328,7 +328,7 @@ impl Grpc { where T: GrpcService, T::ResponseBody: Body + Send + 'static, - ::Error: Into, + ::Error: Into, { let encoding = CompressionEncoding::from_encoding_header( response.headers(), diff --git a/tonic/src/client/service.rs b/tonic/src/client/service.rs index 8f300c366..1a166a766 100644 --- a/tonic/src/client/service.rs +++ b/tonic/src/client/service.rs @@ -14,7 +14,7 @@ pub trait GrpcService { /// Responses body given by the service. type ResponseBody: Body; /// Errors produced by the service. - type Error: Into; + type Error: Into; /// The future response value. type Future: Future, Self::Error>>; @@ -32,9 +32,9 @@ pub trait GrpcService { impl GrpcService for T where T: Service, Response = http::Response>, - T::Error: Into, + T::Error: Into, ResBody: Body, - ::Error: Into, + ::Error: Into, { type ResponseBody = ResBody; type Error = T::Error; diff --git a/tonic/src/codec/decode.rs b/tonic/src/codec/decode.rs index f1e640650..ebad0249a 100644 --- a/tonic/src/codec/decode.rs +++ b/tonic/src/codec/decode.rs @@ -65,7 +65,7 @@ impl Streaming { ) -> Self where B: Body + Send + 'static, - B::Error: Into, + B::Error: Into, D: Decoder + Send + 'static, { Self::new( @@ -81,7 +81,7 @@ impl Streaming { pub fn new_empty(decoder: D, body: B) -> Self where B: Body + Send + 'static, - B::Error: Into, + B::Error: Into, D: Decoder + Send + 'static, { Self::new(decoder, body, Direction::EmptyResponse, None, None) @@ -97,7 +97,7 @@ impl Streaming { ) -> Self where B: Body + Send + 'static, - B::Error: Into, + B::Error: Into, D: Decoder + Send + 'static, { Self::new( @@ -118,7 +118,7 @@ impl Streaming { ) -> Self where B: Body + Send + 'static, - B::Error: Into, + B::Error: Into, D: Decoder + Send + 'static, { let buffer_size = decoder.buffer_settings().buffer_size; diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs index 2ed0d220e..27830aca7 100644 --- a/tonic/src/lib.rs +++ b/tonic/src/lib.rs @@ -128,7 +128,7 @@ pub use request::{IntoRequest, IntoStreamingRequest, Request}; pub use response::Response; pub use status::{Code, ConnectError, Status, TimeoutExpired}; -pub(crate) type Error = Box; +pub(crate) type BoxError = Box; #[doc(hidden)] #[cfg(feature = "codegen")] diff --git a/tonic/src/server/grpc.rs b/tonic/src/server/grpc.rs index 8915df304..81afd93d1 100644 --- a/tonic/src/server/grpc.rs +++ b/tonic/src/server/grpc.rs @@ -228,7 +228,7 @@ where where S: UnaryService, B: Body + Send + 'static, - B::Error: Into + Send, + B::Error: Into + Send, { let accept_encoding = CompressionEncoding::from_accept_encoding_header( req.headers(), @@ -272,7 +272,7 @@ where S: ServerStreamingService, S::ResponseStream: Send + 'static, B: Body + Send + 'static, - B::Error: Into + Send, + B::Error: Into + Send, { let accept_encoding = CompressionEncoding::from_accept_encoding_header( req.headers(), @@ -312,7 +312,7 @@ where where S: ClientStreamingService, B: Body + Send + 'static, - B::Error: Into + Send + 'static, + B::Error: Into + Send + 'static, { let accept_encoding = CompressionEncoding::from_accept_encoding_header( req.headers(), @@ -346,7 +346,7 @@ where S: StreamingService + Send, S::ResponseStream: Send + 'static, B: Body + Send + 'static, - B::Error: Into + Send, + B::Error: Into + Send, { let accept_encoding = CompressionEncoding::from_accept_encoding_header( req.headers(), @@ -371,7 +371,7 @@ where ) -> Result, Status> where B: Body + Send + 'static, - B::Error: Into + Send, + B::Error: Into + Send, { let request_compression_encoding = self.request_encoding_if_supported(&request)?; @@ -404,7 +404,7 @@ where ) -> Result>, Status> where B: Body + Send + 'static, - B::Error: Into + Send, + B::Error: Into + Send, { let encoding = self.request_encoding_if_supported(&request)?; diff --git a/tonic/src/service/router.rs b/tonic/src/service/router.rs index 9507edb83..c059e908a 100644 --- a/tonic/src/service/router.rs +++ b/tonic/src/service/router.rs @@ -143,10 +143,10 @@ async fn unimplemented() -> impl axum::response::IntoResponse { impl Service> for Routes where B: http_body::Body + Send + 'static, - B::Error: Into, + B::Error: Into, { type Response = Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = RoutesFuture; #[inline] @@ -168,7 +168,7 @@ impl fmt::Debug for RoutesFuture { } impl Future for RoutesFuture { - type Output = Result, crate::Error>; + type Output = Result, crate::BoxError>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match ready!(Pin::new(&mut self.as_mut().0).poll(cx)) { diff --git a/tonic/src/status.rs b/tonic/src/status.rs index b848cb1c0..73382707e 100644 --- a/tonic/src/status.rs +++ b/tonic/src/status.rs @@ -883,10 +883,10 @@ impl From for i32 { #[cfg(test)] mod tests { use super::*; - use crate::Error; + use crate::BoxError; #[derive(Debug)] - struct Nested(Error); + struct Nested(BoxError); impl fmt::Display for Nested { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -911,7 +911,7 @@ mod tests { #[test] fn from_error_unknown() { - let orig: Error = "peek-a-boo".into(); + let orig: BoxError = "peek-a-boo".into(); let found = Status::from_error(orig); assert_eq!(found.code(), Code::Unknown); diff --git a/tonic/src/transport/channel/endpoint.rs b/tonic/src/transport/channel/endpoint.rs index b760e1ee9..4da6cdabf 100644 --- a/tonic/src/transport/channel/endpoint.rs +++ b/tonic/src/transport/channel/endpoint.rs @@ -46,7 +46,7 @@ impl Endpoint { pub fn new(dst: D) -> Result where D: TryInto, - D::Error: Into, + D::Error: Into, { let me = dst.try_into().map_err(|e| Error::from_source(e.into()))?; #[cfg(feature = "tls")] @@ -366,7 +366,7 @@ impl Endpoint { C: Service + Send + 'static, C::Response: rt::Read + rt::Write + Send + Unpin, C::Future: Send, - crate::Error: From + Send, + crate::BoxError: From + Send, { let connector = self.connector(connector); @@ -391,7 +391,7 @@ impl Endpoint { C: Service + Send + 'static, C::Response: rt::Read + rt::Write + Send + Unpin, C::Future: Send, - crate::Error: From + Send, + crate::BoxError: From + Send, { let connector = self.connector(connector); if let Some(connect_timeout) = self.connect_timeout { diff --git a/tonic/src/transport/channel/mod.rs b/tonic/src/transport/channel/mod.rs index d22ced98d..2fe8a2753 100644 --- a/tonic/src/transport/channel/mod.rs +++ b/tonic/src/transport/channel/mod.rs @@ -64,14 +64,14 @@ const DEFAULT_BUFFER_SIZE: usize = 1024; /// cloning the `Channel` type is cheap and encouraged. #[derive(Clone)] pub struct Channel { - svc: Buffer, BoxFuture<'static, Result, crate::Error>>>, + svc: Buffer, BoxFuture<'static, Result, crate::BoxError>>>, } /// A future that resolves to an HTTP response. /// /// This is returned by the `Service::call` on [`Channel`]. pub struct ResponseFuture { - inner: BufferResponseFuture, crate::Error>>>, + inner: BufferResponseFuture, crate::BoxError>>>, } impl Channel { @@ -147,7 +147,7 @@ impl Channel { pub(crate) fn new(connector: C, endpoint: Endpoint) -> Self where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Send, C::Response: rt::Read + rt::Write + HyperConnection + Unpin + Send + 'static, { @@ -165,7 +165,7 @@ impl Channel { pub(crate) async fn connect(connector: C, endpoint: Endpoint) -> Result where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Unpin + Send, C::Response: rt::Read + rt::Write + HyperConnection + Unpin + Send + 'static, { @@ -184,7 +184,7 @@ impl Channel { pub(crate) fn balance(discover: D, buffer_size: usize, executor: E) -> Self where D: Discover + Unpin + Send + 'static, - D::Error: Into, + D::Error: Into, D::Key: Hash + Send + Clone, E: Executor> + Send + Sync + 'static, { diff --git a/tonic/src/transport/channel/service/add_origin.rs b/tonic/src/transport/channel/service/add_origin.rs index dc205411b..c9e0f7472 100644 --- a/tonic/src/transport/channel/service/add_origin.rs +++ b/tonic/src/transport/channel/service/add_origin.rs @@ -30,10 +30,10 @@ impl Service> for AddOrigin where T: Service>, T::Future: Send + 'static, - T::Error: Into, + T::Error: Into, { type Response = T::Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { diff --git a/tonic/src/transport/channel/service/connection.rs b/tonic/src/transport/channel/service/connection.rs index ea23bb32f..d7aa64baa 100644 --- a/tonic/src/transport/channel/service/connection.rs +++ b/tonic/src/transport/channel/service/connection.rs @@ -21,14 +21,14 @@ use tower::{ use tower_service::Service; pub(crate) struct Connection { - inner: BoxService, Response, crate::Error>, + inner: BoxService, Response, crate::BoxError>, } impl Connection { fn new(connector: C, endpoint: Endpoint, is_lazy: bool) -> Self where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Send, C::Response: rt::Read + rt::Write + Unpin + Send + 'static, { @@ -77,10 +77,13 @@ impl Connection { } } - pub(crate) async fn connect(connector: C, endpoint: Endpoint) -> Result + pub(crate) async fn connect( + connector: C, + endpoint: Endpoint, + ) -> Result where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Unpin + Send, C::Response: rt::Read + rt::Write + Unpin + Send + 'static, { @@ -90,7 +93,7 @@ impl Connection { pub(crate) fn lazy(connector: C, endpoint: Endpoint) -> Self where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Send, C::Response: rt::Read + rt::Write + Unpin + Send + 'static, { @@ -100,7 +103,7 @@ impl Connection { impl Service> for Connection { type Response = Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -138,7 +141,7 @@ impl From> for SendRequest { impl tower::Service> for SendRequest { type Response = Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -171,12 +174,12 @@ impl MakeSendRequestService { impl tower::Service for MakeSendRequestService where C: Service + Send + 'static, - C::Error: Into + Send, + C::Error: Into + Send, C::Future: Send, C::Response: rt::Read + rt::Write + Unpin + Send, { type Response = SendRequest; - type Error = crate::Error; + type Error = crate::BoxError; type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { diff --git a/tonic/src/transport/channel/service/connector.rs b/tonic/src/transport/channel/service/connector.rs index cf28cdef7..4a6010a82 100644 --- a/tonic/src/transport/channel/service/connector.rs +++ b/tonic/src/transport/channel/service/connector.rs @@ -35,7 +35,7 @@ where C: Service, C::Response: rt::Read + rt::Write + Unpin + Send + 'static, C::Future: Send + 'static, - crate::Error: From + Send + 'static, + crate::BoxError: From + Send + 'static, { type Response = BoxedIo; type Error = ConnectError; @@ -69,7 +69,7 @@ where }; } - Ok::<_, crate::Error>(BoxedIo::new(io)) + Ok::<_, crate::BoxError>(BoxedIo::new(io)) } .await .map_err(ConnectError) diff --git a/tonic/src/transport/channel/service/discover.rs b/tonic/src/transport/channel/service/discover.rs index b1d3c3331..ca292252c 100644 --- a/tonic/src/transport/channel/service/discover.rs +++ b/tonic/src/transport/channel/service/discover.rs @@ -24,7 +24,7 @@ impl DynamicServiceStream { } impl Stream for DynamicServiceStream { - type Item = DiscoverResult; + type Item = DiscoverResult; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let c = &mut self.changes; diff --git a/tonic/src/transport/channel/service/reconnect.rs b/tonic/src/transport/channel/service/reconnect.rs index f6ae2fa0e..491cdb111 100644 --- a/tonic/src/transport/channel/service/reconnect.rs +++ b/tonic/src/transport/channel/service/reconnect.rs @@ -1,4 +1,3 @@ -use crate::Error; use pin_project::pin_project; use std::fmt; use std::{ @@ -13,12 +12,12 @@ use tracing::trace; pub(crate) struct Reconnect where M: Service, - M::Error: Into, + M::Error: Into, { mk_service: M, state: State, target: Target, - error: Option, + error: Option, has_been_connected: bool, is_lazy: bool, } @@ -33,7 +32,7 @@ enum State { impl Reconnect where M: Service, - M::Error: Into, + M::Error: Into, { pub(crate) fn new(mk_service: M, target: Target, is_lazy: bool) -> Self { Reconnect { @@ -52,12 +51,12 @@ where M: Service, S: Service, M::Future: Unpin, - Error: From + From, + crate::BoxError: From + From, Target: Clone, - >::Error: Into, + >::Error: Into, { type Response = S::Response; - type Error = Error; + type Error = crate::BoxError; type Future = ResponseFuture; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -160,7 +159,7 @@ where M::Future: fmt::Debug, M::Response: fmt::Debug, Target: fmt::Debug, - >::Error: Into, + >::Error: Into, { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Reconnect") @@ -183,7 +182,7 @@ pub(crate) struct ResponseFuture { #[derive(Debug)] enum Inner { Future(#[pin] F), - Error(Option), + Error(Option), } impl ResponseFuture { @@ -193,7 +192,7 @@ impl ResponseFuture { } } - pub(crate) fn error(error: crate::Error) -> Self { + pub(crate) fn error(error: crate::BoxError) -> Self { ResponseFuture { inner: Inner::Error(Some(error)), } @@ -203,9 +202,9 @@ impl ResponseFuture { impl Future for ResponseFuture where F: Future>, - E: Into, + E: Into, { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { //self.project().inner.poll(cx).map_err(Into::into) diff --git a/tonic/src/transport/channel/service/tls.rs b/tonic/src/transport/channel/service/tls.rs index efdd8dc91..656e9fb31 100644 --- a/tonic/src/transport/channel/service/tls.rs +++ b/tonic/src/transport/channel/service/tls.rs @@ -32,7 +32,7 @@ impl TlsConnector { assume_http2: bool, #[cfg(feature = "tls-native-roots")] with_native_roots: bool, #[cfg(feature = "tls-webpki-roots")] with_webpki_roots: bool, - ) -> Result { + ) -> Result { let builder = ClientConfig::builder(); let mut roots = RootCertStore::from_iter(trust_anchors); @@ -75,7 +75,7 @@ impl TlsConnector { }) } - pub(crate) async fn connect(&self, io: I) -> Result + pub(crate) async fn connect(&self, io: I) -> Result where I: AsyncRead + AsyncWrite + Send + Unpin + 'static, { diff --git a/tonic/src/transport/channel/tls.rs b/tonic/src/transport/channel/tls.rs index 03dd3b742..0c2eb37e0 100644 --- a/tonic/src/transport/channel/tls.rs +++ b/tonic/src/transport/channel/tls.rs @@ -112,7 +112,7 @@ impl ClientTlsConfig { config } - pub(crate) fn into_tls_connector(self, uri: &Uri) -> Result { + pub(crate) fn into_tls_connector(self, uri: &Uri) -> Result { let domain = match &self.domain { Some(domain) => domain, None => uri.host().ok_or_else(Error::new_invalid_uri)?, diff --git a/tonic/src/transport/error.rs b/tonic/src/transport/error.rs index 92a910498..cdc7a6c54 100644 --- a/tonic/src/transport/error.rs +++ b/tonic/src/transport/error.rs @@ -33,7 +33,7 @@ impl Error { self } - pub(crate) fn from_source(source: impl Into) -> Self { + pub(crate) fn from_source(source: impl Into) -> Self { Error::new(Kind::Transport).with(source) } diff --git a/tonic/src/transport/server/incoming.rs b/tonic/src/transport/server/incoming.rs index e55c6a171..e0751e739 100644 --- a/tonic/src/transport/server/incoming.rs +++ b/tonic/src/transport/server/incoming.rs @@ -22,10 +22,10 @@ use super::service::TlsAcceptor; #[cfg(not(feature = "tls"))] pub(crate) fn tcp_incoming( incoming: impl Stream>, -) -> impl Stream, crate::Error>> +) -> impl Stream, crate::BoxError>> where IO: AsyncRead + AsyncWrite + Unpin + Send + 'static, - IE: Into, + IE: Into, { async_stream::try_stream! { let mut incoming = pin!(incoming); @@ -46,10 +46,10 @@ where pub(crate) fn tcp_incoming( incoming: impl Stream>, tls: Option, -) -> impl Stream, crate::Error>> +) -> impl Stream, crate::BoxError>> where IO: AsyncRead + AsyncWrite + Unpin + Send + 'static, - IE: Into, + IE: Into, { async_stream::try_stream! { let mut incoming = pin!(incoming); @@ -92,7 +92,7 @@ where } } -fn handle_tcp_accept_error(e: impl Into) -> ControlFlow { +fn handle_tcp_accept_error(e: impl Into) -> ControlFlow { let e = e.into(); tracing::debug!(error = %e, "accept loop error"); if let Some(e) = e.downcast_ref::() { @@ -115,10 +115,10 @@ fn handle_tcp_accept_error(e: impl Into) -> ControlFlow( incoming: &mut (impl Stream> + Unpin), - tasks: &mut tokio::task::JoinSet, crate::Error>>, + tasks: &mut tokio::task::JoinSet, crate::BoxError>>, ) -> SelectOutput where - IE: Into, + IE: Into, { if tasks.is_empty() { return match incoming.try_next().await { @@ -151,8 +151,8 @@ where enum SelectOutput { Incoming(A), Io(ServerIo), - TcpErr(crate::Error), - TlsErr(crate::Error), + TcpErr(crate::BoxError), + TlsErr(crate::BoxError), Done, } @@ -203,7 +203,7 @@ impl TcpIncoming { addr: SocketAddr, nodelay: bool, keepalive: Option, - ) -> Result { + ) -> Result { let std_listener = StdTcpListener::bind(addr)?; std_listener.set_nonblocking(true)?; @@ -220,7 +220,7 @@ impl TcpIncoming { listener: TcpListener, nodelay: bool, keepalive: Option, - ) -> Result { + ) -> Result { Ok(Self { inner: TcpListenerStream::new(listener), nodelay, diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 6e1fcc461..a8b23a1ff 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -68,7 +68,8 @@ use tower::{ Service, ServiceBuilder, ServiceExt, }; -type BoxService = tower::util::BoxCloneService, Response, crate::Error>; +type BoxService = + tower::util::BoxCloneService, Response, crate::BoxError>; type TraceInterceptor = Arc) -> tracing::Span + Send + Sync + 'static>; const DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS: u64 = 20; @@ -539,14 +540,14 @@ impl Server { Service, Response = Response> + Clone + Send + 'static, <>::Service as Service>>::Future: Send + 'static, <>::Service as Service>>::Error: - Into + Send + 'static, + Into + Send + 'static, I: Stream>, IO: AsyncRead + AsyncWrite + Connected + Unpin + Send + 'static, IO::ConnectInfo: Clone + Send + Sync + 'static, - IE: Into, + IE: Into, F: Future, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { let trace_interceptor = self.trace_interceptor.clone(); let concurrency_limit = self.concurrency_limit; @@ -787,9 +788,9 @@ impl Router { Service, Response = Response> + Clone + Send + 'static, <>::Service as Service>>::Future: Send + 'static, <>::Service as Service>>::Error: - Into + Send, + Into + Send, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { let incoming = TcpIncoming::new(addr, self.server.tcp_nodelay, self.server.tcp_keepalive) .map_err(super::Error::from_source)?; @@ -819,9 +820,9 @@ impl Router { Service, Response = Response> + Clone + Send + 'static, <>::Service as Service>>::Future: Send + 'static, <>::Service as Service>>::Error: - Into + Send, + Into + Send, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { let incoming = TcpIncoming::new(addr, self.server.tcp_nodelay, self.server.tcp_keepalive) .map_err(super::Error::from_source)?; @@ -844,15 +845,15 @@ impl Router { I: Stream>, IO: AsyncRead + AsyncWrite + Connected + Unpin + Send + 'static, IO::ConnectInfo: Clone + Send + Sync + 'static, - IE: Into, + IE: Into, L: Layer, L::Service: Service, Response = Response> + Clone + Send + 'static, <>::Service as Service>>::Future: Send + 'static, <>::Service as Service>>::Error: - Into + Send, + Into + Send, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { self.server .serve_with_shutdown::<_, _, future::Ready<()>, _, _, ResBody>( @@ -880,16 +881,16 @@ impl Router { I: Stream>, IO: AsyncRead + AsyncWrite + Connected + Unpin + Send + 'static, IO::ConnectInfo: Clone + Send + Sync + 'static, - IE: Into, + IE: Into, F: Future, L: Layer, L::Service: Service, Response = Response> + Clone + Send + 'static, <>::Service as Service>>::Future: Send + 'static, <>::Service as Service>>::Error: - Into + Send, + Into + Send, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { self.server .serve_with_shutdown(self.routes.prepare(), incoming, Some(signal)) @@ -920,12 +921,12 @@ struct Svc { impl Service> for Svc where S: Service, Response = Response>, - S::Error: Into, + S::Error: Into, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { type Response = Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = SvcFuture; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -964,11 +965,11 @@ struct SvcFuture { impl Future for SvcFuture where F: Future, E>>, - E: Into, + E: Into, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { - type Output = Result, crate::Error>; + type Output = Result, crate::BoxError>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); @@ -1000,12 +1001,12 @@ where IO: Connected, S: Service, Response = Response> + Clone + Send + 'static, S::Future: Send + 'static, - S::Error: Into + Send, + S::Error: Into + Send, ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, + ResBody::Error: Into, { type Response = BoxService; - type Error = crate::Error; + type Error = crate::BoxError; type Future = future::Ready>; fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { diff --git a/tonic/src/transport/server/service/recover_error.rs b/tonic/src/transport/server/service/recover_error.rs index 60b0d9a7b..4818e768c 100644 --- a/tonic/src/transport/server/service/recover_error.rs +++ b/tonic/src/transport/server/service/recover_error.rs @@ -25,10 +25,10 @@ impl RecoverError { impl Service for RecoverError where S: Service>, - S::Error: Into, + S::Error: Into, { type Response = Response>; - type Error = crate::Error; + type Error = crate::BoxError; type Future = ResponseFuture; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -51,12 +51,12 @@ pub(crate) struct ResponseFuture { impl Future for ResponseFuture where F: Future, E>>, - E: Into, + E: Into, { - type Output = Result>, crate::Error>; + type Output = Result>, crate::BoxError>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let result: Result, crate::Error> = + let result: Result, crate::BoxError> = ready!(self.project().inner.poll(cx)).map_err(Into::into); match result { diff --git a/tonic/src/transport/server/service/tls.rs b/tonic/src/transport/server/service/tls.rs index c020710fb..d69a6a46b 100644 --- a/tonic/src/transport/server/service/tls.rs +++ b/tonic/src/transport/server/service/tls.rs @@ -22,7 +22,7 @@ impl TlsAcceptor { identity: Identity, client_ca_root: Option, client_auth_optional: bool, - ) -> Result { + ) -> Result { let builder = ServerConfig::builder(); let builder = match client_ca_root { @@ -49,7 +49,7 @@ impl TlsAcceptor { }) } - pub(crate) async fn accept(&self, io: IO) -> Result, crate::Error> + pub(crate) async fn accept(&self, io: IO) -> Result, crate::BoxError> where IO: AsyncRead + AsyncWrite + Unpin, { diff --git a/tonic/src/transport/server/tls.rs b/tonic/src/transport/server/tls.rs index 2f329cb89..331df8d31 100644 --- a/tonic/src/transport/server/tls.rs +++ b/tonic/src/transport/server/tls.rs @@ -56,7 +56,7 @@ impl ServerTlsConfig { } } - pub(crate) fn tls_acceptor(&self) -> Result { + pub(crate) fn tls_acceptor(&self) -> Result { TlsAcceptor::new( self.identity.clone().unwrap(), self.client_ca_root.clone(), diff --git a/tonic/src/transport/service/grpc_timeout.rs b/tonic/src/transport/service/grpc_timeout.rs index 0b99d2163..019a37a2f 100644 --- a/tonic/src/transport/service/grpc_timeout.rs +++ b/tonic/src/transport/service/grpc_timeout.rs @@ -28,10 +28,10 @@ impl GrpcTimeout { impl Service> for GrpcTimeout where S: Service>, - S::Error: Into, + S::Error: Into, { type Response = S::Response; - type Error = crate::Error; + type Error = crate::BoxError; type Future = ResponseFuture; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -73,9 +73,9 @@ pub(crate) struct ResponseFuture { impl Future for ResponseFuture where F: Future>, - E: Into, + E: Into, { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); diff --git a/tonic/src/transport/service/tls.rs b/tonic/src/transport/service/tls.rs index 958f30c1d..cdc2cf7ee 100644 --- a/tonic/src/transport/service/tls.rs +++ b/tonic/src/transport/service/tls.rs @@ -55,7 +55,7 @@ pub(crate) fn load_identity( pub(crate) fn add_certs_from_pem( mut certs: &mut dyn std::io::BufRead, roots: &mut RootCertStore, -) -> Result<(), crate::Error> { +) -> Result<(), crate::BoxError> { for cert in rustls_pemfile::certs(&mut certs).collect::, _>>()? { roots .add(cert)