From e152c8511bcb626fcbad96c0984a055ce6f77601 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 29 Jun 2021 16:19:26 +0900 Subject: [PATCH] Expose `client_async_tls_with_connector_and_config` --- src/async_std.rs | 17 +++++++++++++---- src/tokio.rs | 10 +++++++++- src/tokio/dummy_tls.rs | 5 ++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/async_std.rs b/src/async_std.rs index bb61263..51cf55a 100644 --- a/src/async_std.rs +++ b/src/async_std.rs @@ -122,7 +122,10 @@ pub(crate) mod dummy_tls { } } - pub(crate) async fn client_async_tls_with_connector_and_config( + /// Creates a WebSocket handshake from a request and a stream, + /// upgrading the stream to TLS if required and using the given + /// connector and WebSocket configuration. + pub async fn client_async_tls_with_connector_and_config( request: R, stream: S, connector: Option, @@ -146,15 +149,21 @@ pub(crate) mod dummy_tls { } #[cfg(not(any(feature = "async-tls", feature = "async-native-tls")))] -use self::dummy_tls::{client_async_tls_with_connector_and_config, AutoStream}; +pub use self::dummy_tls::client_async_tls_with_connector_and_config; +#[cfg(not(any(feature = "async-tls", feature = "async-native-tls")))] +use self::dummy_tls::AutoStream; #[cfg(all(feature = "async-tls", not(feature = "async-native-tls")))] -use crate::async_tls::{client_async_tls_with_connector_and_config, AutoStream}; +pub use crate::async_tls::client_async_tls_with_connector_and_config; +#[cfg(all(feature = "async-tls", not(feature = "async-native-tls")))] +use crate::async_tls::AutoStream; #[cfg(all(feature = "async-tls", not(feature = "async-native-tls")))] type Connector = real_async_tls::TlsConnector; #[cfg(feature = "async-native-tls")] -use self::async_native_tls::{client_async_tls_with_connector_and_config, AutoStream, Connector}; +pub use self::async_native_tls::client_async_tls_with_connector_and_config; +#[cfg(feature = "async-native-tls")] +use self::async_native_tls::{AutoStream, Connector}; /// Type alias for the stream type of the `client_async()` functions. pub type ClientStream = AutoStream; diff --git a/src/tokio.rs b/src/tokio.rs index 8de54b5..9908591 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -82,7 +82,15 @@ use self::tls::{AutoStream, Connector}; feature = "tokio-openssl", feature = "async-tls" )))] -use self::tls::{client_async_tls_with_connector_and_config, AutoStream}; +pub use self::tls::client_async_tls_with_connector_and_config; +#[cfg(not(any( + feature = "tokio-native-tls", + feature = "tokio-rustls-native-certs", + feature = "tokio-rustls-webpki-roots", + feature = "tokio-openssl", + feature = "async-tls" +)))] +use self::tls::AutoStream; /// Creates a WebSocket handshake from a request and a stream. /// For convenience, the user may call this with a url string, a URL, diff --git a/src/tokio/dummy_tls.rs b/src/tokio/dummy_tls.rs index ecf3550..5706b22 100644 --- a/src/tokio/dummy_tls.rs +++ b/src/tokio/dummy_tls.rs @@ -28,7 +28,10 @@ where } } -pub(crate) async fn client_async_tls_with_connector_and_config( +/// Creates a WebSocket handshake from a request and a stream, +/// upgrading the stream to TLS if required and using the given +/// connector and WebSocket configuration. +pub async fn client_async_tls_with_connector_and_config( request: R, stream: S, connector: Option,