From b129320a4e4b2b0d23d475a7923db79a1347088f Mon Sep 17 00:00:00 2001 From: tottoto Date: Thu, 17 Oct 2024 19:21:18 +0900 Subject: [PATCH 1/4] chore: Remove needless lifetime (#2007) --- tonic/src/metadata/key.rs | 4 ++-- tonic/src/metadata/map.rs | 34 +++++++++++++++++----------------- tonic/src/metadata/value.rs | 12 ++++++------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tonic/src/metadata/key.rs b/tonic/src/metadata/key.rs index d520b93b9..d2b6fd9ab 100644 --- a/tonic/src/metadata/key.rs +++ b/tonic/src/metadata/key.rs @@ -204,7 +204,7 @@ impl<'a, VE: ValueEncoding> PartialEq<&'a MetadataKey> for MetadataKey { } } -impl<'a, VE: ValueEncoding> PartialEq> for &'a MetadataKey { +impl PartialEq> for &MetadataKey { #[inline] fn eq(&self, other: &MetadataKey) -> bool { *other == *self @@ -260,7 +260,7 @@ impl<'a, VE: ValueEncoding> PartialEq<&'a str> for MetadataKey { } } -impl<'a, VE: ValueEncoding> PartialEq> for &'a str { +impl PartialEq> for &str { /// Performs a case-insensitive comparison of the string against the header /// name #[inline] diff --git a/tonic/src/metadata/map.rs b/tonic/src/metadata/map.rs index cf6604d85..f5abd108d 100644 --- a/tonic/src/metadata/map.rs +++ b/tonic/src/metadata/map.rs @@ -1274,7 +1274,7 @@ impl<'a> Iterator for IterMut<'a> { // ===== impl ValueDrain ===== -impl<'a, VE: ValueEncoding> Iterator for ValueDrain<'a, VE> { +impl Iterator for ValueDrain<'_, VE> { type Item = MetadataValue; fn next(&mut self) -> Option { @@ -1308,7 +1308,7 @@ impl<'a> Iterator for Keys<'a> { } } -impl<'a> ExactSizeIterator for Keys<'a> {} +impl ExactSizeIterator for Keys<'_> {} // ===== impl Values ==== @@ -1967,7 +1967,7 @@ impl<'a, VE: ValueEncoding> GetAll<'a, VE> { } } -impl<'a, VE: ValueEncoding> PartialEq for GetAll<'a, VE> { +impl PartialEq for GetAll<'_, VE> { fn eq(&self, other: &Self) -> bool { self.inner.iter().eq(other.inner.iter()) } @@ -2051,7 +2051,7 @@ mod into_metadata_key { impl IntoMetadataKey for MetadataKey {} - impl<'a, VE: ValueEncoding> Sealed for &'a MetadataKey { + impl Sealed for &MetadataKey { #[doc(hidden)] #[inline] fn insert( @@ -2070,7 +2070,7 @@ mod into_metadata_key { } } - impl<'a, VE: ValueEncoding> IntoMetadataKey for &'a MetadataKey {} + impl IntoMetadataKey for &MetadataKey {} impl Sealed for &'static str { #[doc(hidden)] @@ -2180,7 +2180,7 @@ mod as_metadata_key { impl AsMetadataKey for MetadataKey {} - impl<'a, VE: ValueEncoding> Sealed for &'a MetadataKey { + impl Sealed for &MetadataKey { #[doc(hidden)] #[inline] fn get(self, map: &MetadataMap) -> Option<&MetadataValue> { @@ -2221,9 +2221,9 @@ mod as_metadata_key { } } - impl<'a, VE: ValueEncoding> AsMetadataKey for &'a MetadataKey {} + impl AsMetadataKey for &MetadataKey {} - impl<'a, VE: ValueEncoding> Sealed for &'a str { + impl Sealed for &str { #[doc(hidden)] #[inline] fn get(self, map: &MetadataMap) -> Option<&MetadataValue> { @@ -2283,7 +2283,7 @@ mod as_metadata_key { } } - impl<'a, VE: ValueEncoding> AsMetadataKey for &'a str {} + impl AsMetadataKey for &str {} impl Sealed for String { #[doc(hidden)] @@ -2346,7 +2346,7 @@ mod as_metadata_key { impl AsMetadataKey for String {} - impl<'a, VE: ValueEncoding> Sealed for &'a String { + impl Sealed for &String { #[doc(hidden)] #[inline] fn get(self, map: &MetadataMap) -> Option<&MetadataValue> { @@ -2405,7 +2405,7 @@ mod as_metadata_key { } } - impl<'a, VE: ValueEncoding> AsMetadataKey for &'a String {} + impl AsMetadataKey for &String {} } mod as_encoding_agnostic_metadata_key { @@ -2442,7 +2442,7 @@ mod as_encoding_agnostic_metadata_key { impl AsEncodingAgnosticMetadataKey for MetadataKey {} - impl<'a, VE: ValueEncoding> Sealed for &'a MetadataKey { + impl Sealed for &MetadataKey { #[doc(hidden)] #[inline] fn contains_key(&self, map: &MetadataMap) -> bool { @@ -2450,9 +2450,9 @@ mod as_encoding_agnostic_metadata_key { } } - impl<'a, VE: ValueEncoding> AsEncodingAgnosticMetadataKey for &'a MetadataKey {} + impl AsEncodingAgnosticMetadataKey for &MetadataKey {} - impl<'a> Sealed for &'a str { + impl Sealed for &str { #[doc(hidden)] #[inline] fn contains_key(&self, map: &MetadataMap) -> bool { @@ -2460,7 +2460,7 @@ mod as_encoding_agnostic_metadata_key { } } - impl<'a> AsEncodingAgnosticMetadataKey for &'a str {} + impl AsEncodingAgnosticMetadataKey for &str {} impl Sealed for String { #[doc(hidden)] @@ -2472,7 +2472,7 @@ mod as_encoding_agnostic_metadata_key { impl AsEncodingAgnosticMetadataKey for String {} - impl<'a> Sealed for &'a String { + impl Sealed for &String { #[doc(hidden)] #[inline] fn contains_key(&self, map: &MetadataMap) -> bool { @@ -2480,7 +2480,7 @@ mod as_encoding_agnostic_metadata_key { } } - impl<'a> AsEncodingAgnosticMetadataKey for &'a String {} + impl AsEncodingAgnosticMetadataKey for &String {} } #[cfg(test)] diff --git a/tonic/src/metadata/value.rs b/tonic/src/metadata/value.rs index eb1bcfab1..eb9eeda1c 100644 --- a/tonic/src/metadata/value.rs +++ b/tonic/src/metadata/value.rs @@ -248,7 +248,7 @@ impl MetadataValue { /// let val = AsciiMetadataValue::try_from(b"\n"); /// assert!(val.is_err()); /// ``` -impl<'a, VE: ValueEncoding> TryFrom<&'a [u8]> for MetadataValue { +impl TryFrom<&[u8]> for MetadataValue { type Error = InvalidMetadataValueBytes; #[inline] @@ -284,7 +284,7 @@ impl<'a, VE: ValueEncoding> TryFrom<&'a [u8]> for MetadataValue { /// let val = AsciiMetadataValue::try_from(b"\n"); /// assert!(val.is_err()); /// ``` -impl<'a, VE: ValueEncoding, const N: usize> TryFrom<&'a [u8; N]> for MetadataValue { +impl TryFrom<&[u8; N]> for MetadataValue { type Error = InvalidMetadataValueBytes; #[inline] @@ -737,14 +737,14 @@ impl PartialOrd> for String { } } -impl<'a, VE: ValueEncoding> PartialEq> for &'a MetadataValue { +impl PartialEq> for &MetadataValue { #[inline] fn eq(&self, other: &MetadataValue) -> bool { **self == *other } } -impl<'a, VE: ValueEncoding> PartialOrd> for &'a MetadataValue { +impl PartialOrd> for &MetadataValue { #[inline] fn partial_cmp(&self, other: &MetadataValue) -> Option { (**self).partial_cmp(other) @@ -771,14 +771,14 @@ where } } -impl<'a, VE: ValueEncoding> PartialEq> for &'a str { +impl PartialEq> for &str { #[inline] fn eq(&self, other: &MetadataValue) -> bool { *other == *self } } -impl<'a, VE: ValueEncoding> PartialOrd> for &'a str { +impl PartialOrd> for &str { #[inline] fn partial_cmp(&self, other: &MetadataValue) -> Option { self.as_bytes().partial_cmp(other.inner.as_bytes()) From 80dd77aaac709226d10f40a9a3e069d8a6ac8d19 Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 18 Oct 2024 01:09:21 +0900 Subject: [PATCH 2/4] chore(server): Remove unnecessary service bound (#2010) --- tonic/src/transport/server/mod.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 62006e1a6..25659b81b 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -900,13 +900,6 @@ impl Router { pub fn into_service(self) -> L::Service where L: Layer, - L::Service: - Service, Response = Response> + Clone + Send + 'static, - <>::Service as Service>>::Future: Send + 'static, - <>::Service as Service>>::Error: - Into + Send, - ResBody: http_body::Body + Send + 'static, - ResBody::Error: Into, { self.server.service_builder.service(self.routes.prepare()) } From 58345a6bf29b4c17eccc949dd6d7640928dff0cc Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 18 Oct 2024 02:48:53 +0900 Subject: [PATCH 3/4] chore: Update to tower 0.5 (#1892) --- examples/Cargo.toml | 4 ++-- interop/Cargo.toml | 2 +- tests/compression/Cargo.toml | 4 ++-- tests/integration_tests/Cargo.toml | 4 ++-- tonic-web/Cargo.toml | 2 +- tonic/Cargo.toml | 4 ++-- tonic/src/transport/channel/mod.rs | 16 ++++++++-------- tonic/src/transport/server/mod.rs | 4 ++-- tonic/src/transport/server/service/io.rs | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index faf296a98..d6cc1b5c6 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -300,7 +300,7 @@ tonic-types = { path = "../tonic-types", optional = true } async-stream = { version = "0.3", optional = true } tokio-stream = { version = "0.1", optional = true } tokio-util = { version = "0.7.8", optional = true } -tower = { version = "0.4", optional = true } +tower = { version = "0.5", optional = true } rand = { version = "0.8", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } @@ -318,7 +318,7 @@ h2 = { version = "0.4", optional = true } tokio-rustls = { version = "0.26", optional = true, features = ["ring", "tls12"], default-features = false } hyper-rustls = { version = "0.27.0", features = ["http2", "ring", "tls12"], optional = true, default-features = false } rustls-pemfile = { version = "2.0.0", optional = true } -tower-http = { version = "0.5", optional = true } +tower-http = { version = "0.6", optional = true } pin-project = { version = "1.0.11", optional = true } [build-dependencies] diff --git a/interop/Cargo.toml b/interop/Cargo.toml index 5ec668f4f..9314cb40a 100644 --- a/interop/Cargo.toml +++ b/interop/Cargo.toml @@ -26,7 +26,7 @@ prost = "0.13" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" tonic = {path = "../tonic", features = ["tls"]} -tower = {version = "0.4"} +tower = "0.5" tracing-subscriber = {version = "0.3"} [build-dependencies] diff --git a/tests/compression/Cargo.toml b/tests/compression/Cargo.toml index a40522fa6..f9ecf1590 100644 --- a/tests/compression/Cargo.toml +++ b/tests/compression/Cargo.toml @@ -19,8 +19,8 @@ prost = "0.13" tokio = {version = "1.0", features = ["macros", "rt-multi-thread", "net"]} tokio-stream = "0.1" tonic = {path = "../../tonic", features = ["gzip", "zstd"]} -tower = {version = "0.4", features = []} -tower-http = {version = "0.5", features = ["map-response-body", "map-request-body"]} +tower = "0.5" +tower-http = {version = "0.6", features = ["map-response-body", "map-request-body"]} [build-dependencies] tonic-build = {path = "../../tonic-build" } diff --git a/tests/integration_tests/Cargo.toml b/tests/integration_tests/Cargo.toml index 238fe374d..8993723a9 100644 --- a/tests/integration_tests/Cargo.toml +++ b/tests/integration_tests/Cargo.toml @@ -21,8 +21,8 @@ http = "1" http-body = "1" hyper-util = "0.1" tokio-stream = {version = "0.1.5", features = ["net"]} -tower = {version = "0.4", features = []} -tower-http = { version = "0.5", features = ["set-header", "trace"] } +tower = "0.5" +tower-http = { version = "0.6", features = ["set-header", "trace"] } tower-service = "0.3" tracing = "0.1" diff --git a/tonic-web/Cargo.toml b/tonic-web/Cargo.toml index 85e5ccb9c..3cd17ec09 100644 --- a/tonic-web/Cargo.toml +++ b/tonic-web/Cargo.toml @@ -25,7 +25,7 @@ pin-project = "1" tonic = { version = "0.12", path = "../tonic", default-features = false } tower-service = "0.3" tower-layer = "0.3" -tower-http = { version = "0.5", features = ["cors"] } +tower-http = { version = "0.6", features = ["cors"] } tracing = "0.1" [dev-dependencies] diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 15f3dc49e..62df328b1 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -84,7 +84,7 @@ hyper = {version = "1", features = ["http1", "http2"], optional = true} hyper-util = { version = "0.1.4", features = ["tokio"], optional = true } socket2 = { version = "0.5", optional = true, features = ["all"] } tokio = {version = "1", default-features = false, optional = true} -tower = {version = "0.4.7", default-features = false, optional = true} +tower = {version = "0.5", default-features = false, optional = true} axum = {version = "0.7", default-features = false, optional = true} # rustls @@ -107,7 +107,7 @@ quickcheck_macros = "1.0" rand = "0.8" static_assertions = "1.0" tokio = {version = "1.0", features = ["rt", "macros"]} -tower = {version = "0.4.7", features = ["full"]} +tower = {version = "0.5", features = ["full"]} [package.metadata.docs.rs] all-features = true diff --git a/tonic/src/transport/channel/mod.rs b/tonic/src/transport/channel/mod.rs index ed8d22275..d22ced98d 100644 --- a/tonic/src/transport/channel/mod.rs +++ b/tonic/src/transport/channel/mod.rs @@ -29,14 +29,13 @@ use tokio::sync::mpsc::{channel, Sender}; use hyper::rt; use tower::balance::p2c::Balance; use tower::{ - buffer::{self, Buffer}, + buffer::{future::ResponseFuture as BufferResponseFuture, Buffer}, discover::{Change, Discover}, - util::{BoxService, Either}, + util::BoxService, Service, }; type BoxFuture<'a, T> = Pin + Send + 'a>>; -type Svc = Either, Response, crate::Error>>; const DEFAULT_BUFFER_SIZE: usize = 1024; @@ -65,14 +64,14 @@ const DEFAULT_BUFFER_SIZE: usize = 1024; /// cloning the `Channel` type is cheap and encouraged. #[derive(Clone)] pub struct Channel { - svc: Buffer>, + svc: Buffer, BoxFuture<'static, Result, crate::Error>>>, } /// A future that resolves to an HTTP response. /// /// This is returned by the `Service::call` on [`Channel`]. pub struct ResponseFuture { - inner: buffer::future::ResponseFuture<>>::Future>, + inner: BufferResponseFuture, crate::Error>>>, } impl Channel { @@ -156,7 +155,8 @@ impl Channel { let executor = endpoint.executor.clone(); let svc = Connection::lazy(connector, endpoint); - let (svc, worker) = Buffer::pair(Either::A(svc), buffer_size); + let (svc, worker) = Buffer::pair(svc, buffer_size); + executor.execute(worker); Channel { svc } @@ -175,7 +175,7 @@ impl Channel { let svc = Connection::connect(connector, endpoint) .await .map_err(super::Error::from_source)?; - let (svc, worker) = Buffer::pair(Either::A(svc), buffer_size); + let (svc, worker) = Buffer::pair(svc, buffer_size); executor.execute(worker); Ok(Channel { svc }) @@ -191,7 +191,7 @@ impl Channel { let svc = Balance::new(discover); let svc = BoxService::new(svc); - let (svc, worker) = Buffer::pair(Either::B(svc), buffer_size); + let (svc, worker) = Buffer::pair(svc, buffer_size); executor.execute(Box::pin(worker)); Channel { svc } diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 25659b81b..6e1fcc461 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -1030,10 +1030,10 @@ where .layer(BoxCloneService::layer()) .map_request(move |mut request: Request| { match &conn_info { - tower::util::Either::A(inner) => { + tower::util::Either::Left(inner) => { request.extensions_mut().insert(inner.clone()); } - tower::util::Either::B(inner) => { + tower::util::Either::Right(inner) => { #[cfg(feature = "tls")] { request.extensions_mut().insert(inner.clone()); diff --git a/tonic/src/transport/server/service/io.rs b/tonic/src/transport/server/service/io.rs index e4588abe7..bfb441e88 100644 --- a/tonic/src/transport/server/service/io.rs +++ b/tonic/src/transport/server/service/io.rs @@ -37,9 +37,9 @@ impl ServerIo { IO: Connected, { match self { - Self::Io(io) => Either::A(io.connect_info()), + Self::Io(io) => Either::Left(io.connect_info()), #[cfg(feature = "tls")] - Self::TlsIo(io) => Either::B(io.connect_info()), + Self::TlsIo(io) => Either::Right(io.connect_info()), } } } From 758d4f9a95d9752465baa7db10ab6cc069fef00b Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 18 Oct 2024 07:54:40 +0900 Subject: [PATCH 4/4] chore: Rename Error to BoxError (#2011) --- tonic/src/body.rs | 2 +- tonic/src/client/grpc.rs | 10 ++-- tonic/src/client/service.rs | 6 +-- tonic/src/codec/decode.rs | 8 ++-- tonic/src/lib.rs | 2 +- tonic/src/server/grpc.rs | 12 ++--- tonic/src/service/router.rs | 6 +-- tonic/src/status.rs | 6 +-- tonic/src/transport/channel/endpoint.rs | 6 +-- tonic/src/transport/channel/mod.rs | 10 ++-- .../transport/channel/service/add_origin.rs | 4 +- .../transport/channel/service/connection.rs | 21 +++++---- .../transport/channel/service/connector.rs | 4 +- .../src/transport/channel/service/discover.rs | 2 +- .../transport/channel/service/reconnect.rs | 23 +++++---- tonic/src/transport/channel/service/tls.rs | 4 +- tonic/src/transport/channel/tls.rs | 2 +- tonic/src/transport/error.rs | 2 +- tonic/src/transport/server/incoming.rs | 22 ++++----- tonic/src/transport/server/mod.rs | 47 ++++++++++--------- .../transport/server/service/recover_error.rs | 10 ++-- tonic/src/transport/server/service/tls.rs | 4 +- tonic/src/transport/server/tls.rs | 2 +- tonic/src/transport/service/grpc_timeout.rs | 8 ++-- tonic/src/transport/service/tls.rs | 2 +- 25 files changed, 114 insertions(+), 111 deletions(-) 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)