Skip to main content

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;
25pub mod extensions;
26#[cfg(feature = "handshake")]
27pub mod handshake;
28pub mod protocol;
29#[cfg(all(feature = "proxy", feature = "handshake"))]
30pub mod proxy;
31#[cfg(feature = "handshake")]
32mod server;
33pub mod stream;
34#[cfg(all(any(feature = "native-tls", feature = "__rustls-tls"), feature = "handshake"))]
35mod tls;
36pub mod util;
37
38const READ_BUFFER_CHUNK_SIZE: usize = 4096;
39type ReadBuffer = buffer::ReadBuffer<READ_BUFFER_CHUNK_SIZE>;
40
41pub use crate::{
42    error::{Error, Result},
43    protocol::{frame::Utf8Bytes, Message, WebSocket},
44};
45// re-export bytes since used in `Message` API.
46pub use bytes::Bytes;
47
48#[cfg(feature = "handshake")]
49pub use crate::{
50    client::{client, connect, ClientRequestBuilder},
51    handshake::{client::ClientHandshake, server::ServerHandshake, HandshakeError},
52    server::{accept, accept_hdr, accept_hdr_with_config, accept_with_config},
53};
54
55#[cfg(all(any(feature = "native-tls", feature = "__rustls-tls"), feature = "handshake"))]
56pub use tls::{client_tls, client_tls_with_config, Connector};