From 29e528d1bcd178798671c0fed09681b95e27a860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 28 May 2020 16:09:50 +0300 Subject: [PATCH] Switch from deprecated tokio-tls to tokio-native-tls --- Cargo.toml | 10 +++++----- README.md | 4 ++-- examples/tokio-echo.rs | 4 ++-- src/lib.rs | 6 +++--- src/tokio.rs | 26 +++++++++++++------------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1061be2..09a90a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,10 @@ tokio-runtime = ["tokio"] gio-runtime = ["gio", "glib"] async-tls = ["real-async-tls"] async-native-tls = ["async-std-runtime", "real-async-native-tls"] -tokio-tls = ["tokio-runtime", "real-tokio-tls", "real-native-tls", "tungstenite/tls"] +tokio-native-tls = ["tokio-runtime", "real-tokio-native-tls", "real-native-tls", "tungstenite/tls"] [package.metadata.docs.rs] -features = ["async-std-runtime", "tokio-runtime", "gio-runtime", "async-tls", "async-native-tls", "tokio-tls"] +features = ["async-std-runtime", "tokio-runtime", "gio-runtime", "async-tls", "async-native-tls", "tokio-native-tls"] [dependencies] log = "0.4" @@ -58,10 +58,10 @@ optional = true version = "0.2" features = ["tcp", "dns"] -[dependencies.real-tokio-tls] +[dependencies.real-tokio-native-tls] optional = true -version = "0.3" -package = "tokio-tls" +version = "0.1" +package = "tokio-native-tls" [dependencies.gio] optional = true diff --git a/README.md b/README.md index d95d7e1..6cf42f4 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ integration with various other crates can be enabled via feature flags [async-native-tls](https://crates.io/crates/async-native-tls). * `tokio-runtime`: Enables the `tokio` module, which provides integration with the [tokio](https://tokio.rs) runtime. - * `tokio-tls`: Enables the additional functions in the `tokio` module to - implement TLS via [tokio-tls](https://crates.io/crates/tokio-tls). + * `tokio-native-tls`: Enables the additional functions in the `tokio` module to + implement TLS via [tokio-native-tls](https://crates.io/crates/tokio-native-tls). * `gio-runtime`: Enables the `gio` module, which provides integration with the [gio](https://gtk-rs.org) runtime. diff --git a/examples/tokio-echo.rs b/examples/tokio-echo.rs index d3b7a43..39dca63 100644 --- a/examples/tokio-echo.rs +++ b/examples/tokio-echo.rs @@ -2,9 +2,9 @@ use async_tungstenite::{tokio::connect_async, tungstenite::Message}; use futures::prelude::*; async fn run() -> Result<(), Box> { - #[cfg(any(feature = "async-tls", feature = "tokio-tls"))] + #[cfg(any(feature = "async-tls", feature = "tokio-native-tls"))] let url = "wss://echo.websocket.org"; - #[cfg(not(any(feature = "async-tls", feature = "tokio-tls")))] + #[cfg(not(any(feature = "async-tls", feature = "tokio-native-tls")))] let url = "ws://echo.websocket.org"; let (mut ws_stream, _) = connect_async(url).await?; diff --git a/src/lib.rs b/src/lib.rs index 92e49a2..513b15f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,8 +16,8 @@ //! [async-native-tls](https://crates.io/crates/async-native-tls). //! * `tokio-runtime`: Enables the `tokio` module, which provides integration //! with the [tokio](https://tokio.rs) runtime. -//! * `tokio-tls`: Enables the additional functions in the `tokio` module to -//! implement TLS via [tokio-tls](https://crates.io/crates/tokio-tls). +//! * `tokio-native-tls`: Enables the additional functions in the `tokio` module to +//! implement TLS via [tokio-native-tls](https://crates.io/crates/tokio-native-tls). //! * `gio-runtime`: Enables the `gio` module, which provides integration with //! the [gio](https://www.gtk-rs.org) runtime. //! @@ -41,7 +41,7 @@ mod handshake; #[cfg(any( feature = "async-tls", feature = "async-native-tls", - feature = "tokio-tls", + feature = "tokio-native-tls", ))] pub mod stream; diff --git a/src/tokio.rs b/src/tokio.rs index d5751a9..b2adcc5 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -10,10 +10,10 @@ use super::{domain, port, WebSocketStream}; use futures_io::{AsyncRead, AsyncWrite}; -#[cfg(feature = "tokio-tls")] +#[cfg(feature = "tokio-native-tls")] pub(crate) mod tokio_tls { - use real_tokio_tls::TlsConnector as AsyncTlsConnector; - use real_tokio_tls::TlsStream; + use real_tokio_native_tls::TlsConnector as AsyncTlsConnector; + use real_tokio_native_tls::TlsStream; use tungstenite::client::{uri_mode, IntoClientRequest}; use tungstenite::handshake::client::Request; @@ -89,7 +89,7 @@ pub(crate) mod tokio_tls { } } -#[cfg(not(any(feature = "async-tls", feature = "tokio-tls")))] +#[cfg(not(any(feature = "async-tls", feature = "tokio-native-tls")))] pub(crate) mod dummy_tls { use futures_io::{AsyncRead, AsyncWrite}; @@ -141,18 +141,18 @@ pub(crate) mod dummy_tls { } } -#[cfg(not(any(feature = "async-tls", feature = "tokio-tls")))] +#[cfg(not(any(feature = "async-tls", feature = "tokio-native-tls")))] use self::dummy_tls::{client_async_tls_with_connector_and_config, AutoStream}; -#[cfg(all(feature = "async-tls", not(feature = "tokio-tls")))] +#[cfg(all(feature = "async-tls", not(feature = "tokio-native-tls")))] use crate::async_tls::{client_async_tls_with_connector_and_config, AutoStream}; -#[cfg(all(feature = "async-tls", not(feature = "tokio-tls")))] +#[cfg(all(feature = "async-tls", not(feature = "tokio-native-tls")))] type Connector = real_async_tls::TlsConnector; -#[cfg(feature = "tokio-tls")] +#[cfg(feature = "tokio-native-tls")] use self::tokio_tls::{client_async_tls_with_connector_and_config, AutoStream, Connector}; -#[cfg(feature = "tokio-tls")] +#[cfg(feature = "tokio-native-tls")] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required. pub async fn client_async_tls( @@ -167,7 +167,7 @@ where client_async_tls_with_connector_and_config(request, stream, None, None).await } -#[cfg(feature = "tokio-tls")] +#[cfg(feature = "tokio-native-tls")] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// WebSocket configuration. @@ -184,7 +184,7 @@ where client_async_tls_with_connector_and_config(request, stream, None, config).await } -#[cfg(feature = "tokio-tls")] +#[cfg(feature = "tokio-native-tls")] /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required and using the given /// connector. @@ -241,7 +241,7 @@ where client_async_tls_with_connector_and_config(request, TokioAdapter(socket), None, config).await } -#[cfg(any(feature = "async-tls", feature = "tokio-tls"))] +#[cfg(any(feature = "async-tls", feature = "tokio-native-tls"))] /// Connect to a given URL using the provided TLS connector. pub async fn connect_async_with_tls_connector( request: R, @@ -259,7 +259,7 @@ where connect_async_with_tls_connector_and_config(request, connector, None).await } -#[cfg(any(feature = "async-tls", feature = "tokio-tls"))] +#[cfg(any(feature = "async-tls", feature = "tokio-native-tls"))] /// Connect to a given URL using the provided TLS connector. pub async fn connect_async_with_tls_connector_and_config( request: R,