Skip to main content

ntex/ws/
mod.rs

1//! WebSocket protocol support.
2//!
3//! Use [`handshake()`] or [`handshake_response()`] to perform a server-side
4//! opening handshake, and [`WsClient`] to establish a client connection.
5//!
6//! Framed communication uses [`Codec`] to encode and decode [`Frame`]s and
7//! [`Message`]s. On the client side, [`WsConnection::start()`] runs a frame
8//! handling service, [`WsConnection::receiver()`] returns a stream of frames,
9//! and [`WsConnection::sink()`] returns a [`WsSink`] for sending messages.
10//!
11//! [`WsTransport`] is a byte-stream filter instead: binary and continuation
12//! frames are exposed as raw bytes, text frames are rejected, and control
13//! frames are handled internally. Use [`WsConnection::into_transport()`] to
14//! run a byte-oriented protocol over a WebSocket connection.
15mod cfg;
16mod client;
17mod codec;
18mod frame;
19mod handshake;
20mod mask;
21mod proto;
22mod sink;
23mod transport;
24
25pub mod error;
26
27pub use self::cfg::WsClientConfig;
28pub use self::client::{WsClient, WsConnection};
29pub use self::codec::{Codec, Frame, Item, Message};
30pub use self::frame::Parser;
31pub use self::handshake::{handshake, handshake_response, verify_handshake};
32pub use self::proto::{CloseCode, CloseReason, OpCode, hash_key};
33pub use self::sink::WsSink;
34pub use self::transport::{WsTransport, WsTransportService};
35
36pub(crate) use self::cfg::is_token;