Expand description
Async WebSocket usage.
This library is an implementation of WebSocket handshakes and streams. It is based on the crate which implements all required WebSocket protocol logic. So this crate basically just brings tokio support / tokio integration to it.
Each WebSocket stream implements the required Stream
and Sink
traits,
so the socket is just a stream of messages coming in and going out.
Re-exports§
pub use tungstenite;
Structs§
- WebSocket
Stream - A wrapper around an underlying raw stream which implements the WebSocket protocol.
Enums§
- Connector
- A connector that can be used when establishing connections, allowing to control whether
native-tls
orrustls
is used to create a TLS connection. Or TLS can be disabled with thePlain
variant. - Maybe
TlsStream - A stream that might be protected with TLS.
Functions§
- accept_
async - Accepts a new WebSocket connection with the provided stream.
- accept_
async_ with_ config - The same as
accept_async()
but the one can specify a websocket configuration. Please refer toaccept_async()
for more details. - accept_
hdr_ async - Accepts a new WebSocket connection with the provided stream.
- accept_
hdr_ async_ with_ config - The same as
accept_hdr_async()
but the one can specify a websocket configuration. Please refer toaccept_hdr_async()
for more details. - client_
async - 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 withRequest
allows the user to add a WebSocket protocol or other custom headers. - client_
async_ tls - Creates a WebSocket handshake from a request and a stream, upgrading the stream to TLS if required.
- client_
async_ tls_ with_ config - The same as
client_async_tls()
but the one can specify a websocket configuration, and an optional connector. If no connector is specified, a default one will be created. - client_
async_ with_ config - The same as
client_async()
but the one can specify a websocket configuration. Please refer toclient_async()
for more details. - connect_
async - Connect to a given URL.
- connect_
async_ tls_ with_ config - The same as
connect_async()
but the one can specify a websocket configuration, and a TLS connector to use. Please refer toconnect_async()
for more details.disable_nagle
specifies if the Nagle’s algorithm must be disabled, i.e.set_nodelay(true)
. If you don’t know what the Nagle’s algorithm is, better leave it tofalse
. - connect_
async_ with_ config - The same as
connect_async()
but the one can specify a websocket configuration. Please refer toconnect_async()
for more details.disable_nagle
specifies if the Nagle’s algorithm must be disabled, i.e.set_nodelay(true)
. If you don’t know what the Nagle’s algorithm is, better leave it set tofalse
.