Skip to content

Commit

Permalink
Fix unused dependencies and tls configuration in connector.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudy committed May 20, 2024
1 parent 87916af commit 0ade9a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ grpc-web = [
"dep:bytes",
"dep:http",
"dep:hyper",
"dep:hyper-util",
"dep:tracing-subscriber",
"dep:tower",
]
Expand All @@ -315,15 +316,16 @@ tracing = ["dep:tracing", "dep:tracing-subscriber"]
# "dep:warp",
# ]
# hyper-warp-multiplex = ["hyper-warp"]
uds = ["tokio-stream/net", "dep:tower", "dep:hyper"]
uds = ["tokio-stream/net", "dep:tower", "dep:hyper", "dep:hyper-util"]
streaming = ["tokio-stream", "dep:h2"]
mock = ["tokio-stream", "dep:tower", "dep:hyper-util"]
tower = ["dep:hyper", "dep:tower", "dep:http"]
tower = ["dep:hyper", "dep:hyper-util", "dep:tower", "dep:http"]
json-codec = ["dep:serde", "dep:serde_json", "dep:bytes"]
compression = ["tonic/gzip"]
tls = ["tonic/tls"]
tls-rustls = [
"dep:hyper",
"dep:hyper-util",
"dep:hyper-rustls",
"dep:tower",
"tower-http/util",
Expand Down
5 changes: 5 additions & 0 deletions tonic/src/transport/service/connector.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[cfg(feature = "tls")]
use std::fmt;

use std::task::{Context, Poll};

use http::Uri;
Expand Down Expand Up @@ -102,14 +104,17 @@ where
}

/// Error returned when trying to connect to an HTTPS endpoint without TLS enabled.
#[cfg(feature = "tls")]
#[derive(Debug)]
pub(crate) struct HttpsUriWithoutTlsSupport(());

#[cfg(feature = "tls")]
impl fmt::Display for HttpsUriWithoutTlsSupport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Connecting to HTTPS without TLS enabled")
}
}

// std::error::Error only requires a type to impl Debug and Display
#[cfg(feature = "tls")]
impl std::error::Error for HttpsUriWithoutTlsSupport {}

0 comments on commit 0ade9a8

Please sign in to comment.