Skip to main content

Module ws

Module ws 

Source
Expand description

WebSocket protocol support.

Use handshake() or handshake_response() to perform a server-side opening handshake, and WsClient to establish a client connection.

Framed communication uses Codec to encode and decode Frames and Messages. On the client side, WsConnection::start() runs a frame handling service, WsConnection::receiver() returns a stream of frames, and WsConnection::sink() returns a WsSink for sending messages.

WsTransport is a byte-stream filter instead: binary and continuation frames are exposed as raw bytes, text frames are rejected, and control frames are handled internally. Use WsConnection::into_transport() to run a byte-oriented protocol over a WebSocket connection.

Modules§

error
WebSocket protocol related errors.

Structs§

CloseReason
Reason supplied in a WebSocket close control frame.
Codec
Encoder and decoder for WebSocket frames.
Parser
WebSocket frame parser.
WsClient
Builder for establishing a WebSocket client connection.
WsClientConfig
Configuration for a WebSocket client connection.
WsConnection
An established WebSocket client connection.
WsSink
A clonable handle for sending messages over a WebSocket connection.
WsTransport
I/O filter that exposes binary WebSocket messages as a byte stream.
WsTransportService
Service that adds a WsTransport filter to an I/O stream.

Enums§

CloseCode
Status code used to indicate why an endpoint is closing the WebSocket connection.
Frame
A decoded WebSocket frame.
Item
A fragment in a WebSocket continuation sequence.
Message
An outgoing WebSocket message.
OpCode
WebSocket frame operation codes defined by RFC 6455.

Functions§

handshake
Verifies a WebSocket opening-handshake request and creates its response.
handshake_response
Creates a WebSocket opening-handshake response.
hash_key
Computes the Sec-WebSocket-Accept value for a client handshake key.
verify_handshake
Verifies a WebSocket opening-handshake request.