diff --git a/src/async_std.rs b/src/async_std.rs index 457813c..1805ca8 100644 --- a/src/async_std.rs +++ b/src/async_std.rs @@ -154,13 +154,16 @@ 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}; +/// Type alias for the stream type of the `client_async()` functions. +pub type ClientStream = AutoStream; + #[cfg(feature = "async-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( request: R, stream: S, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -177,7 +180,7 @@ pub async fn client_async_tls_with_config( request: R, stream: S, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -194,7 +197,7 @@ pub async fn client_async_tls_with_connector( request: R, stream: S, connector: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -203,10 +206,13 @@ where client_async_tls_with_connector_and_config(request, stream, connector, None).await } +/// Type alias for the stream type of the `connect_async()` functions. +pub type ConnectStream = ClientStream; + /// Connect to a given URL. pub async fn connect_async( request: R, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -217,7 +223,7 @@ where pub async fn connect_async_with_config( request: R, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -236,7 +242,7 @@ where pub async fn connect_async_with_tls_connector( request: R, connector: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -249,7 +255,7 @@ pub async fn connect_async_with_tls_connector_and_config( request: R, connector: Option, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { diff --git a/src/async_tls.rs b/src/async_tls.rs index fca24cf..00bcc5d 100644 --- a/src/async_tls.rs +++ b/src/async_tls.rs @@ -42,12 +42,15 @@ where } } +/// Type alias for the stream type of the `client_async()` functions. +pub type ClientStream = AutoStream; + /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required. pub async fn client_async_tls( request: R, stream: S, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -63,7 +66,7 @@ pub async fn client_async_tls_with_config( request: R, stream: S, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -79,7 +82,7 @@ pub async fn client_async_tls_with_connector( request: R, stream: S, connector: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -96,7 +99,7 @@ pub async fn client_async_tls_with_connector_and_config( stream: S, connector: Option, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, diff --git a/src/gio.rs b/src/gio.rs index 875181c..2ca16b7 100644 --- a/src/gio.rs +++ b/src/gio.rs @@ -13,12 +13,13 @@ use tungstenite::stream::Mode; use crate::{client_async_with_config, domain, port, Response, WebSocketConfig, WebSocketStream}; -type MaybeTlsStream = IOStreamAsyncReadWrite; +/// Type alias for the stream type of the `connect_async()` functions. +pub type ConnectStream = IOStreamAsyncReadWrite; /// Connect to a given URL. pub async fn connect_async( request: R, -) -> Result<(WebSocketStream, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -29,7 +30,7 @@ where pub async fn connect_async_with_config( request: R, config: Option, -) -> Result<(WebSocketStream, Response), Error> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { diff --git a/src/lib.rs b/src/lib.rs index af99e04..5a52e65 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -272,8 +272,7 @@ impl WebSocketStream { } /// Returns a reference to the configuration of the tungstenite stream. - pub fn get_config(&self) -> &WebSocketConfig - { + pub fn get_config(&self) -> &WebSocketConfig { self.inner.get_config() } diff --git a/src/tokio.rs b/src/tokio.rs index b2adcc5..b0eabc5 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -152,13 +152,16 @@ type Connector = real_async_tls::TlsConnector; #[cfg(feature = "tokio-native-tls")] use self::tokio_tls::{client_async_tls_with_connector_and_config, AutoStream, Connector}; +/// Type alias for the stream type of the `client_async()` functions. +pub type ClientStream = AutoStream; + #[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( request: R, stream: S, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -175,7 +178,7 @@ pub async fn client_async_tls_with_config( request: R, stream: S, config: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -192,7 +195,7 @@ pub async fn client_async_tls_with_connector( request: R, stream: S, connector: Option, -) -> Result<(WebSocketStream>, Response), Error> +) -> Result<(WebSocketStream>, Response), Error> where R: IntoClientRequest + Unpin, S: 'static + AsyncRead + AsyncWrite + Unpin, @@ -201,16 +204,13 @@ where client_async_tls_with_connector_and_config(request, stream, connector, None).await } +/// Type alias for the stream type of the `connect_async()` functions. +pub type ConnectStream = ClientStream>; + /// Connect to a given URL. pub async fn connect_async( request: R, -) -> Result< - ( - WebSocketStream>>, - Response, - ), - Error, -> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -221,13 +221,7 @@ where pub async fn connect_async_with_config( request: R, config: Option, -) -> Result< - ( - WebSocketStream>>, - Response, - ), - Error, -> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -246,13 +240,7 @@ where pub async fn connect_async_with_tls_connector( request: R, connector: Option, -) -> Result< - ( - WebSocketStream>>, - Response, - ), - Error, -> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, { @@ -265,13 +253,7 @@ pub async fn connect_async_with_tls_connector_and_config( request: R, connector: Option, config: Option, -) -> Result< - ( - WebSocketStream>>, - Response, - ), - Error, -> +) -> Result<(WebSocketStream, Response), Error> where R: IntoClientRequest + Unpin, {