Module ws
Handle WebSocket connections.
Example
use ;
let app = new.route;
async
async
# let _: Router = app;
Passing data and/or state to an on_upgrade callback
use ;
async
async
let app = new
.route
.with_state;
# let _: Router = app;
Read and write concurrently
If you need to read and write concurrently from a WebSocket you can use
StreamExt::split:
use ;
use ;
async
async
async
Modules
-
close_code
Constants for
CloseCodes. - rejection WebSocket specific rejections.
Structs
- CloseFrame A struct representing the close command.
-
DefaultOnFailedUpgrade
The default
OnFailedUpgradeused byWebSocketUpgrade. - Utf8Bytes UTF-8 wrapper for [Bytes].
- WebSocket A stream of WebSocket messages.
- WebSocketUpgrade Extractor for establishing WebSocket connections.
Enums
- Message A WebSocket message.
Traits
- OnFailedUpgrade What to do when a connection upgrade fails.
Type Aliases
- CloseCode Status code used to indicate why an endpoint is closing the WebSocket connection.