Tune tokio's feature gates to play nice together

pull/59/head
Constantin Nickel 4 years ago committed by Sebastian Dröge
parent dd066e2737
commit 96b1f87dfb
  1. 61
      src/tokio.rs

@ -11,7 +11,7 @@ use super::{domain, port, WebSocketStream};
use futures_io::{AsyncRead, AsyncWrite}; use futures_io::{AsyncRead, AsyncWrite};
#[cfg(feature = "tokio-rustls")] #[cfg(all(feature = "tokio-rustls", not(feature = "tokio-native-tls")))]
pub(crate) mod tokio_tls { pub(crate) mod tokio_tls {
use real_tokio_rustls::{client::TlsStream, TlsConnector as AsyncTlsConnector}; use real_tokio_rustls::{client::TlsStream, TlsConnector as AsyncTlsConnector};
use real_tokio_rustls::rustls::ClientConfig; use real_tokio_rustls::rustls::ClientConfig;
@ -167,7 +167,10 @@ pub(crate) mod tokio_tls {
} }
} }
#[cfg(feature = "tokio-openssl")] #[cfg(all(
feature = "tokio-openssl",
not(any(feature = "tokio-native-tls", feature = "tokio-rustls"))
))]
pub(crate) mod tokio_tls { pub(crate) mod tokio_tls {
use openssl::ssl::{ConnectConfiguration, SslConnector, SslMethod}; use openssl::ssl::{ConnectConfiguration, SslConnector, SslMethod};
use real_tokio_openssl::connect; use real_tokio_openssl::connect;
@ -324,7 +327,14 @@ pub(crate) mod dummy_tls {
)))] )))]
use self::dummy_tls::{client_async_tls_with_connector_and_config, AutoStream}; use self::dummy_tls::{client_async_tls_with_connector_and_config, AutoStream};
#[cfg(all(feature = "async-tls", not(feature = "tokio-native-tls")))] #[cfg(all(
feature = "async-tls",
not(any(
feature = "tokio-rustls",
feature = "tokio-native-tls",
feature = "tokio-openssl"
))
))]
pub(crate) mod async_tls_adapter { pub(crate) mod async_tls_adapter {
use super::{ use super::{
Error, IntoClientRequest, Response, TokioAdapter, WebSocketConfig, WebSocketStream, Error, IntoClientRequest, Response, TokioAdapter, WebSocketConfig, WebSocketStream,
@ -361,22 +371,37 @@ pub(crate) mod async_tls_adapter {
pub type AutoStream<S> = MaybeTlsStream<TokioAdapter<S>>; pub type AutoStream<S> = MaybeTlsStream<TokioAdapter<S>>;
} }
#[cfg(all(feature = "async-tls", not(any(feature = "tokio-native-tls", feature = "tokio-openssl"))))]
#[cfg(all(
feature = "async-tls",
not(any(
feature = "tokio-rustls",
feature = "tokio-native-tls",
feature = "tokio-openssl"
))
))]
pub use self::async_tls_adapter::client_async_tls_with_connector_and_config; pub use self::async_tls_adapter::client_async_tls_with_connector_and_config;
#[cfg(all(feature = "async-tls", not(any(feature = "tokio-native-tls", feature = "tokio-openssl"))))] #[cfg(all(
feature = "async-tls",
not(any(
feature = "tokio-rustls",
feature = "tokio-native-tls",
feature = "tokio-openssl"
))
))]
use self::async_tls_adapter::{AutoStream, Connector}; use self::async_tls_adapter::{AutoStream, Connector};
#[cfg(feature = "tokio-native-tls")] #[cfg(any(
use self::tokio_tls::{client_async_tls_with_connector_and_config, AutoStream, Connector}; feature = "tokio-rustls",
feature = "tokio-native-tls",
#[cfg(feature = "tokio-rustls")] feature = "tokio-openssl"
pub use self::tokio_tls::client_async_tls_with_connector_and_config; ))]
#[cfg(feature = "tokio-rustls")]
use self::tokio_tls::{AutoStream, Connector};
#[cfg(feature = "tokio-openssl")]
pub use self::tokio_tls::client_async_tls_with_connector_and_config; pub use self::tokio_tls::client_async_tls_with_connector_and_config;
#[cfg(feature = "tokio-openssl")] #[cfg(any(
feature = "tokio-rustls",
feature = "tokio-native-tls",
feature = "tokio-openssl"
))]
use self::tokio_tls::{AutoStream, Connector}; use self::tokio_tls::{AutoStream, Connector};
/// Creates a WebSocket handshake from a request and a stream. /// Creates a WebSocket handshake from a request and a stream.
@ -528,7 +553,7 @@ where
client_async_tls_with_connector_and_config(request, stream, connector, None).await client_async_tls_with_connector_and_config(request, stream, connector, None).await
} }
#[cfg(feature = "tokio-openssl")] #[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))]
/// Creates a WebSocket handshake from a request and a stream, /// Creates a WebSocket handshake from a request and a stream,
/// upgrading the stream to TLS if required. /// upgrading the stream to TLS if required.
pub async fn client_async_tls<R, S>( pub async fn client_async_tls<R, S>(
@ -549,7 +574,7 @@ where
client_async_tls_with_connector_and_config(request, stream, None, None).await client_async_tls_with_connector_and_config(request, stream, None, None).await
} }
#[cfg(feature = "tokio-openssl")] #[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))]
/// Creates a WebSocket handshake from a request and a stream, /// Creates a WebSocket handshake from a request and a stream,
/// upgrading the stream to TLS if required and using the given /// upgrading the stream to TLS if required and using the given
/// WebSocket configuration. /// WebSocket configuration.
@ -572,7 +597,7 @@ where
client_async_tls_with_connector_and_config(request, stream, None, config).await client_async_tls_with_connector_and_config(request, stream, None, config).await
} }
#[cfg(feature = "tokio-openssl")] #[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))]
/// Creates a WebSocket handshake from a request and a stream, /// Creates a WebSocket handshake from a request and a stream,
/// upgrading the stream to TLS if required and using the given /// upgrading the stream to TLS if required and using the given
/// connector. /// connector.

Loading…
Cancel
Save