[−][src]Function async_tungstenite::tokio::client_async
pub async fn client_async<'a, R, S>(
request: R,
stream: S
) -> Result<(WebSocketStream<TokioAdapter<S>>, Response), Error> where
R: IntoClientRequest + Unpin,
S: AsyncRead + AsyncWrite + Unpin,
Creates a WebSocket handshake from a request and a stream.
For convenience, the user may call this with a url string, a URL,
or a Request
. Calling with Request
allows the user to add
a WebSocket protocol or other custom headers.
Internally, this custom creates a handshake representation and returns
a future representing the resolution of the WebSocket handshake. The
returned future will resolve to either WebSocketStream<S>
or Error
depending on whether the handshake is successful.
This is typically used for clients who have already established, for example, a TCP connection to the remote server.