Crate ratchet_rs

Source
Expand description

A fully asynchronous implementation of RFC6455 (The WebSocket protocol). Complete with an optional implementation of RFC7692 (Compression Extensions For WebSocket).

§Features

  • Implement your own own extensions using ratchet_ext.
  • Per-message deflate with ratchet_deflate or enable with the deflate feature.
  • Split WebSocket with the split feature.

§Error handling

Ratchet is strict over its implementation of The WebSocket protocol and as such any errors in a session may result in the closure of the session when performing a send or receive operation; it is possible to perform a liveliness check on a WebSocket by invoking the is_closed function. If an error is encountered, then an attempt to close the session cleanly is performed and an error is returned so it is clear that the connection may have been closed.

Possible errors that may be encountered during an upgraded session are protocol violations by the peer or an IO error.

Re-exports§

pub use ratchet_ext;

Structs§

CloseReason
A reason for closing the WebSocket connection.
Error
The errors that may occur during a WebSocket connection.
FrameHeader
A frame’s header.
Header
Represents a parsed header.
HeaderMap
A set of HTTP headers
HeaderValue
Represents an HTTP header field value.
NoExt
An extension stub that does nothing.
NoExtDecoder
NoExtEncoder
NoExtProvider
An extension provider stub that will always succeed with NoExt.
RsvBits
A structure containing the bits that an extension may set high during a session.
SubprotocolRegistry
A subprotocol registry that is used for negotiating a possible subprotocol to use for a connection.
UpgradedClient
A structure representing an upgraded WebSocket session and an optional subprotocol that was negotiated during the upgrade.
UpgradedServer
A structure representing an upgraded WebSocket session and an optional subprotocol that was negotiated during the upgrade.
WebSocket
An upgraded WebSocket stream.
WebSocketClientBuilder
A builder to construct WebSocket clients.
WebSocketConfig
A configuration for building a WebSocket.
WebSocketResponse
A response to send to a client if the connection will not be upgraded.
WebSocketServerBuilder
A builder to construct WebSocket servers.
WebSocketUpgrader
Represents a client connection that has been accepted and the upgrade request validated. This may be used to validate the request by a user and opt to either continue the upgrade or reject the connection - such as if the target path does not exist.

Enums§

CloseCode
Additional implementation sources:
CloseState
Denotes the current state of a WebSocket session.
ErrorKind
A type of error represented.
HttpError
HTTP errors.
Message
A received WebSocket frame.
MessageType
A message type to send.
OpCode
A data code for a frame.
PayloadType
The type of a payload to send to a peer.
ProtocolError
WebSocket protocol errors.
Role
The role of a WebSocket.

Traits§

Extension
A negotiated WebSocket extension.
ExtensionDecoder
A per-message frame decoder.
ExtensionEncoder
A per-message frame encoder.
ExtensionProvider
A trait for negotiating an extension during a WebSocket handshake.
ReunitableExtension
A trait for permitting a matched encoder and decoder to be reunited into an extension.
SplittableExtension
A trait for permitting an extension to be split into its encoder and decoder halves. Allowing for a WebSocket to be split into its sender and receiver halves.
TryIntoRequest
A trait for creating a request from a type.
WebSocketStream
A stream representing a WebSocket connection.

Functions§

accept
Execute a server handshake on the provided stream.
accept_with
Execute a server handshake on the provided stream. An attempt will be made to negotiate the extension and subprotocols provided.
subscribe
Execute a WebSocket client handshake on stream, opting for no compression on messages and no subprotocol.
subscribe_with
Execute a WebSocket client handshake on stream, attempting to negotiate the extension and a subprotocol.