stream-tungstenite 0.6.1

A streaming implementation of the Tungstenite WebSocket protocol
Documentation
// Suppress missing_errors_doc for the entire crate - error documentation is centralized in the error module
#![allow(clippy::missing_errors_doc)]

//! stream-tungstenite: WebSocket client with automatic reconnection.
//!
//! This library provides a robust WebSocket client that handles:
//! - Automatic reconnection with configurable retry strategies
//! - Application-level handshakes (authentication, subscriptions)
//! - Extension system for lifecycle and message handling
//! - Connection state management and monitoring
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use stream_tungstenite::{WebSocketClient, ClientConfig};
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     // Create client with builder pattern
//!     let client = WebSocketClient::builder("wss://example.com/ws")
//!         .receive_timeout(std::time::Duration::from_secs(30))
//!         .build();
//!
//!     // Subscribe to messages before running
//!     let mut messages = client.subscribe();
//!
//!     // Run client in background
//!     let client = Arc::new(client);
//!     tokio::spawn({
//!         let client = client.clone();
//!         async move { client.run().await }
//!     });
//!
//!     // Receive messages
//!     while let Ok(msg) = messages.recv().await {
//!         println!("Received: {:?}", msg);
//!     }
//!
//!     Ok(())
//! }
//! ```
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │                      WebSocketClient                            │
//! │  - High-level API for WebSocket connections                     │
//! │  - Automatic reconnection with retry strategies                 │
//! │  - Message broadcasting via channels                            │
//! └─────────────────────────────────────────────────────────────────┘
//!//!          ┌───────────────────┼───────────────────┐
//!          ▼                   ▼                   ▼
//! ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
//! │   Handshake     │ │   Extension     │ │   Connection    │
//! │   - Auth        │ │   - Lifecycle   │ │   - State       │
//! │   - Subscribe   │ │   - Messages    │ │   - Retry       │
//! │   - Chained     │ │   - Logging     │ │   - Supervisor  │
//! └─────────────────┘ └─────────────────┘ └─────────────────┘
//! ```

// Core modules
pub mod client;
pub mod error;

// Layer modules
pub mod connection;
pub mod context;
pub mod extension;
pub mod handshake;
pub mod message;
pub mod transport;

/// Re-export tokio-tungstenite types
pub mod tokio_tungstenite {
    pub use tokio_tungstenite::*;
}

/// Prelude for convenient imports
pub mod prelude {
    pub use crate::client::*;
    pub use crate::connection::{
        ConnectionEvent, ConnectionSnapshot, ConnectionStatus, ExponentialBackoff, FixedDelay,
        NoRetry, RetryStrategy,
    };
    pub use crate::context::ConnectionContext;
    pub use crate::error::*;
    pub use crate::extension::{Extension, ExtensionHost};
    pub use crate::extension::{LoggingExtension, StatusViewer};
    pub use crate::handshake::{
        AuthHandshaker, ChainedHandshaker, NoOpHandshaker, SubscribeHandshaker,
    };
    pub use crate::handshake::{BoxHandshaker, Handshaker};
    pub use crate::message::SharedMessage;
}

// Re-export main types at crate root
pub use client::{ClientConfig, Sender, WebSocketClient, WebSocketClientBuilder};
pub use connection::ConnectionEvent;
pub use error::{
    ClientError, ConnectError, DisconnectReason, HandshakeError, ReceiveError, SendError,
};
pub use message::SharedMessage;