Expand description
async WebSocket client functionality (requires a browser (WASM) or tokio (native) executors)
§TLS crypto provider (native)
Native secure (wss://) connections use tungstenite with
rustls. Since rustls 0.23, a process-level crypto
provider must be installed before the first secure connection — typically by
the application or a higher-level SDK at startup:
rustls::crypto::ring::default_provider().install_default().unwrap();If exactly one rustls provider is compiled into the binary, it is selected
automatically and no explicit install is needed; an install is only required
when none — or more than one — provider is present. With more than one and no
installed default, opening a wss:// connection fails with “Could not
automatically determine the process-level CryptoProvider”. In the
browser/WASM environment TLS is handled by the host WebSocket, so no
provider is required.
Re-exports§
pub use config::WebSocketConfig;pub use error::Error;pub use options::ConnectOptions;pub use options::ConnectStrategy;pub use result::Result;pub use message::*;
Modules§
- bindings
- Low-level bindings to the underlying browser/Node.js WebSocket interface.
- config
- WebSocket client configuration options
- error
- WebSocket client error type and its conversions.
- message
- WebSocket client message types exchanged with the server.
- options
- Connection options controlling connect and reconnect behavior.
- result
- Result type alias used throughout the WebSocket client.
Structs§
- WebSocket
- An async WebSocket implementation capable of operating uniformly under a browser-backed executor in WASM and under native tokio-runtime.
- _WSI
- Platform-specific (WASM/browser) WebSocket interface backing the
WebSocketclient; owns the underlying socket, connection settings, channels and reconnection state.
Traits§
- Handshake
- Trait implemented by custom handshake handlers that negotiate with the server immediately after the socket opens and before it is marked connected.
- Resolver
- Trait implemented by URL resolvers that supply the destination URL dynamically when no explicit URL has been configured.
Type Aliases§
- Connect
Result - Result of a connect attempt. On success yields
Some(receiver)when the caller did not block on the connection (the receiver fires once connected), orNonewhen the connect call blocked until the connection was established. - Handshake
Fn - Shared closure invoked to perform a custom handshake negotiation using the supplied send/receive channels before the connection is considered ready.
- Handshake
FnReturn - The boxed future returned by a
HandshakeFn, resolving once the handshake completes (or fails). - Resolver
Result - Result of a
Resolver::resolve_urlcall, yielding the destination URL. - WebSocket
Error - Alias for the WebSocket client
Errortype.