From a2468d0431c7b1a5b4272f97df02e9850c773c8d Mon Sep 17 00:00:00 2001 From: Constantin Nickel Date: Thu, 15 Oct 2020 16:28:14 +0200 Subject: [PATCH] Implement the `tokio::client_async_tls*` functions for `async-tls` and `tokio-rustls` --- src/tokio.rs | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/tokio.rs b/src/tokio.rs index afe5ed6..bc6291b 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -504,7 +504,11 @@ where /// Type alias for the stream type of the `client_async()` functions. pub type ClientStream = AutoStream; -#[cfg(feature = "tokio-native-tls")] +#[cfg(any( + feature = "tokio-native-tls", + feature = "tokio-rustls", + all(feature = "async-tls", not(feature = "tokio-openssl")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required. pub async fn client_async_tls( @@ -519,7 +523,11 @@ where client_async_tls_with_connector_and_config(request, stream, None, None).await } -#[cfg(feature = "tokio-native-tls")] +#[cfg(any( + feature = "tokio-native-tls", + feature = "tokio-rustls", + all(feature = "async-tls", not(feature = "tokio-openssl")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// WebSocket configuration. @@ -536,7 +544,11 @@ where client_async_tls_with_connector_and_config(request, stream, None, config).await } -#[cfg(feature = "tokio-native-tls")] +#[cfg(any( + feature = "tokio-native-tls", + feature = "tokio-rustls", + all(feature = "async-tls", not(feature = "tokio-openssl")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// connector. @@ -553,7 +565,10 @@ where client_async_tls_with_connector_and_config(request, stream, connector, None).await } -#[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))] +#[cfg(all( + feature = "tokio-openssl", + not(any(feature = "tokio-native-tls", feature = "tokio-rustls")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required. pub async fn client_async_tls( @@ -574,7 +589,10 @@ where client_async_tls_with_connector_and_config(request, stream, None, None).await } -#[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))] +#[cfg(all( + feature = "tokio-openssl", + not(any(feature = "tokio-native-tls", feature = "tokio-rustls")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// WebSocket configuration. @@ -597,7 +615,10 @@ where client_async_tls_with_connector_and_config(request, stream, None, config).await } -#[cfg(all(feature = "tokio-openssl", not(feature = "tokio-native-tls")))] +#[cfg(all( + feature = "tokio-openssl", + not(any(feature = "tokio-native-tls", feature = "tokio-rustls")) +))] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// connector.