tungstenite/
lib.rs

1//! Lightweight, flexible WebSockets for Rust.
2#![deny(
3    missing_docs,
4    missing_copy_implementations,
5    missing_debug_implementations,
6    trivial_casts,
7    trivial_numeric_casts,
8    unstable_features,
9    unused_must_use,
10    unused_mut,
11    unused_imports,
12    unused_import_braces
13)]
14// This can be removed when `error::Error::Http`, `handshake::HandshakeError::Interrupted` and
15// `handshake::server::ErrorResponse` are boxed.
16#![allow(clippy::result_large_err)]
17
18#[cfg(feature = "handshake")]
19pub use http;
20
21pub mod buffer;
22#[cfg(feature = "handshake")]
23pub mod client;
24pub mod error;
25#[cfg(feature = "handshake")]
26pub mod handshake;
27pub mod protocol;
28#[cfg(feature = "handshake")]
29mod server;
30pub mod stream;
31#[cfg(all(any(feature = "native-tls", feature = "__rustls-tls"), feature = "handshake"))]
32mod tls;
33mod utf8;
34pub mod util;
35
36const READ_BUFFER_CHUNK_SIZE: usize = 4096;
37type ReadBuffer = buffer::ReadBuffer<READ_BUFFER_CHUNK_SIZE>;
38
39pub use crate::{
40    error::{Error, Result},
41    protocol::{frame::Utf8Bytes, Message, WebSocket},
42};
43// re-export bytes since used in `Message` API.
44pub use bytes::Bytes;
45
46#[cfg(feature = "handshake")]
47pub use crate::{
48    client::{client, connect, ClientRequestBuilder},
49    handshake::{client::ClientHandshake, server::ServerHandshake, HandshakeError},
50    server::{accept, accept_hdr, accept_hdr_with_config, accept_with_config},
51};
52
53#[cfg(all(any(feature = "native-tls", feature = "__rustls-tls"), feature = "handshake"))]
54pub use tls::{client_tls, client_tls_with_config, Connector};