Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hyperium/tonic
Browse files Browse the repository at this point in the history
  • Loading branch information
jenr24-architect committed Oct 21, 2024
2 parents 43b4214 + 758d4f9 commit 0176510
Show file tree
Hide file tree
Showing 35 changed files with 159 additions and 163 deletions.
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion interop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tests/compression/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 2 additions & 2 deletions tests/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ http-body = "1"
hyper-util = "0.1"
rustls = {version = "0.23", features = ["ring"]}
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"

Expand Down
2 changes: 1 addition & 1 deletion tonic-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
Expand All @@ -110,7 +110,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
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub type BoxBody = http_body_util::combinators::UnsyncBoxBody<bytes::Bytes, crat
pub fn boxed<B>(body: B) -> BoxBody
where
B: http_body::Body<Data = bytes::Bytes> + Send + 'static,
B::Error: Into<crate::Error>,
B::Error: Into<crate::BoxError>,
{
body.map_err(crate::Status::map_error).boxed_unsync()
}
Expand Down
10 changes: 5 additions & 5 deletions tonic/src/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + Send + 'static,
<T::ResponseBody as Body>::Error: Into<crate::Error>,
<T::ResponseBody as Body>::Error: Into<crate::BoxError>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Expand All @@ -232,7 +232,7 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + Send + 'static,
<T::ResponseBody as Body>::Error: Into<crate::Error>,
<T::ResponseBody as Body>::Error: Into<crate::BoxError>,
S: Stream<Item = M1> + Send + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
Expand Down Expand Up @@ -269,7 +269,7 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + Send + 'static,
<T::ResponseBody as Body>::Error: Into<crate::Error>,
<T::ResponseBody as Body>::Error: Into<crate::BoxError>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Expand All @@ -288,7 +288,7 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + Send + 'static,
<T::ResponseBody as Body>::Error: Into<crate::Error>,
<T::ResponseBody as Body>::Error: Into<crate::BoxError>,
S: Stream<Item = M1> + Send + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
Expand Down Expand Up @@ -328,7 +328,7 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + Send + 'static,
<T::ResponseBody as Body>::Error: Into<crate::Error>,
<T::ResponseBody as Body>::Error: Into<crate::BoxError>,
{
let encoding = CompressionEncoding::from_encoding_header(
response.headers(),
Expand Down
6 changes: 3 additions & 3 deletions tonic/src/client/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait GrpcService<ReqBody> {
/// Responses body given by the service.
type ResponseBody: Body;
/// Errors produced by the service.
type Error: Into<crate::Error>;
type Error: Into<crate::BoxError>;
/// The future response value.
type Future: Future<Output = Result<http::Response<Self::ResponseBody>, Self::Error>>;

Expand All @@ -32,9 +32,9 @@ pub trait GrpcService<ReqBody> {
impl<T, ReqBody, ResBody> GrpcService<ReqBody> for T
where
T: Service<http::Request<ReqBody>, Response = http::Response<ResBody>>,
T::Error: Into<crate::Error>,
T::Error: Into<crate::BoxError>,
ResBody: Body,
<ResBody as Body>::Error: Into<crate::Error>,
<ResBody as Body>::Error: Into<crate::BoxError>,
{
type ResponseBody = ResBody;
type Error = T::Error;
Expand Down
8 changes: 4 additions & 4 deletions tonic/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<T> Streaming<T> {
) -> Self
where
B: Body + Send + 'static,
B::Error: Into<crate::Error>,
B::Error: Into<crate::BoxError>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
{
Self::new(
Expand All @@ -81,7 +81,7 @@ impl<T> Streaming<T> {
pub fn new_empty<B, D>(decoder: D, body: B) -> Self
where
B: Body + Send + 'static,
B::Error: Into<crate::Error>,
B::Error: Into<crate::BoxError>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
{
Self::new(decoder, body, Direction::EmptyResponse, None, None)
Expand All @@ -97,7 +97,7 @@ impl<T> Streaming<T> {
) -> Self
where
B: Body + Send + 'static,
B::Error: Into<crate::Error>,
B::Error: Into<crate::BoxError>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
{
Self::new(
Expand All @@ -118,7 +118,7 @@ impl<T> Streaming<T> {
) -> Self
where
B: Body + Send + 'static,
B::Error: Into<crate::Error>,
B::Error: Into<crate::BoxError>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
{
let buffer_size = decoder.buffer_settings().buffer_size;
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub use request::{IntoRequest, IntoStreamingRequest, Request};
pub use response::Response;
pub use status::{Code, ConnectError, Status, TimeoutExpired};

pub(crate) type Error = Box<dyn std::error::Error + Send + Sync>;
pub(crate) type BoxError = Box<dyn std::error::Error + Send + Sync>;

#[doc(hidden)]
#[cfg(feature = "codegen")]
Expand Down
4 changes: 2 additions & 2 deletions tonic/src/metadata/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a, VE: ValueEncoding> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE> {
}
}

impl<'a, VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &'a MetadataKey<VE> {
impl<VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &MetadataKey<VE> {
#[inline]
fn eq(&self, other: &MetadataKey<VE>) -> bool {
*other == *self
Expand Down Expand Up @@ -260,7 +260,7 @@ impl<'a, VE: ValueEncoding> PartialEq<&'a str> for MetadataKey<VE> {
}
}

impl<'a, VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &'a str {
impl<VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &str {
/// Performs a case-insensitive comparison of the string against the header
/// name
#[inline]
Expand Down
34 changes: 17 additions & 17 deletions tonic/src/metadata/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ impl<'a> Iterator for IterMut<'a> {

// ===== impl ValueDrain =====

impl<'a, VE: ValueEncoding> Iterator for ValueDrain<'a, VE> {
impl<VE: ValueEncoding> Iterator for ValueDrain<'_, VE> {
type Item = MetadataValue<VE>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -1308,7 +1308,7 @@ impl<'a> Iterator for Keys<'a> {
}
}

impl<'a> ExactSizeIterator for Keys<'a> {}
impl ExactSizeIterator for Keys<'_> {}

// ===== impl Values ====

Expand Down Expand Up @@ -1967,7 +1967,7 @@ impl<'a, VE: ValueEncoding> GetAll<'a, VE> {
}
}

impl<'a, VE: ValueEncoding> PartialEq for GetAll<'a, VE> {
impl<VE: ValueEncoding> PartialEq for GetAll<'_, VE> {
fn eq(&self, other: &Self) -> bool {
self.inner.iter().eq(other.inner.iter())
}
Expand Down Expand Up @@ -2051,7 +2051,7 @@ mod into_metadata_key {

impl<VE: ValueEncoding> IntoMetadataKey<VE> for MetadataKey<VE> {}

impl<'a, VE: ValueEncoding> Sealed<VE> for &'a MetadataKey<VE> {
impl<VE: ValueEncoding> Sealed<VE> for &MetadataKey<VE> {
#[doc(hidden)]
#[inline]
fn insert(
Expand All @@ -2070,7 +2070,7 @@ mod into_metadata_key {
}
}

impl<'a, VE: ValueEncoding> IntoMetadataKey<VE> for &'a MetadataKey<VE> {}
impl<VE: ValueEncoding> IntoMetadataKey<VE> for &MetadataKey<VE> {}

impl<VE: ValueEncoding> Sealed<VE> for &'static str {
#[doc(hidden)]
Expand Down Expand Up @@ -2180,7 +2180,7 @@ mod as_metadata_key {

impl<VE: ValueEncoding> AsMetadataKey<VE> for MetadataKey<VE> {}

impl<'a, VE: ValueEncoding> Sealed<VE> for &'a MetadataKey<VE> {
impl<VE: ValueEncoding> Sealed<VE> for &MetadataKey<VE> {
#[doc(hidden)]
#[inline]
fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> {
Expand Down Expand Up @@ -2221,9 +2221,9 @@ mod as_metadata_key {
}
}

impl<'a, VE: ValueEncoding> AsMetadataKey<VE> for &'a MetadataKey<VE> {}
impl<VE: ValueEncoding> AsMetadataKey<VE> for &MetadataKey<VE> {}

impl<'a, VE: ValueEncoding> Sealed<VE> for &'a str {
impl<VE: ValueEncoding> Sealed<VE> for &str {
#[doc(hidden)]
#[inline]
fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> {
Expand Down Expand Up @@ -2283,7 +2283,7 @@ mod as_metadata_key {
}
}

impl<'a, VE: ValueEncoding> AsMetadataKey<VE> for &'a str {}
impl<VE: ValueEncoding> AsMetadataKey<VE> for &str {}

impl<VE: ValueEncoding> Sealed<VE> for String {
#[doc(hidden)]
Expand Down Expand Up @@ -2346,7 +2346,7 @@ mod as_metadata_key {

impl<VE: ValueEncoding> AsMetadataKey<VE> for String {}

impl<'a, VE: ValueEncoding> Sealed<VE> for &'a String {
impl<VE: ValueEncoding> Sealed<VE> for &String {
#[doc(hidden)]
#[inline]
fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> {
Expand Down Expand Up @@ -2405,7 +2405,7 @@ mod as_metadata_key {
}
}

impl<'a, VE: ValueEncoding> AsMetadataKey<VE> for &'a String {}
impl<VE: ValueEncoding> AsMetadataKey<VE> for &String {}
}

mod as_encoding_agnostic_metadata_key {
Expand Down Expand Up @@ -2442,25 +2442,25 @@ mod as_encoding_agnostic_metadata_key {

impl<VE: ValueEncoding> AsEncodingAgnosticMetadataKey for MetadataKey<VE> {}

impl<'a, VE: ValueEncoding> Sealed for &'a MetadataKey<VE> {
impl<VE: ValueEncoding> Sealed for &MetadataKey<VE> {
#[doc(hidden)]
#[inline]
fn contains_key(&self, map: &MetadataMap) -> bool {
map.headers.contains_key(&self.inner)
}
}

impl<'a, VE: ValueEncoding> AsEncodingAgnosticMetadataKey for &'a MetadataKey<VE> {}
impl<VE: ValueEncoding> AsEncodingAgnosticMetadataKey for &MetadataKey<VE> {}

impl<'a> Sealed for &'a str {
impl Sealed for &str {
#[doc(hidden)]
#[inline]
fn contains_key(&self, map: &MetadataMap) -> bool {
map.headers.contains_key(*self)
}
}

impl<'a> AsEncodingAgnosticMetadataKey for &'a str {}
impl AsEncodingAgnosticMetadataKey for &str {}

impl Sealed for String {
#[doc(hidden)]
Expand All @@ -2472,15 +2472,15 @@ 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 {
map.headers.contains_key(self.as_str())
}
}

impl<'a> AsEncodingAgnosticMetadataKey for &'a String {}
impl AsEncodingAgnosticMetadataKey for &String {}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 0176510

Please sign in to comment.