1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! # Wynd - A Simple WebSocket Library for Rust
//!
//! Wynd is a lightweight, async WebSocket server library built on Tokio and Tungstenite,
//! designed to provide an excellent developer experience for building WebSocket applications in Rust.
//!
//! ## Features
//!
//! - **Simple API**: Easy-to-use event-driven API with async/await support
//! - **Type Safety**: Strongly typed message events and error handling
//! - **High Performance**: Built on Tokio for excellent async performance
//! - **Connection Management**: Automatic connection lifecycle management
//! - **Error Handling**: Comprehensive error handling with custom error types
//!
//! ## Quick Start
//!
//! ```no_run
//! use wynd::wynd::{Wynd, Standalone};
//!
//! #[tokio::main]
//! async fn main() {
//! let mut wynd: Wynd<Standalone> = Wynd::new();
//!
//! wynd.on_connection(|conn| async move {
//! println!("New connection established: {}", conn.id());
//!
//! conn.on_open(|handle| async move {
//! println!("Connection {} is now open", handle.id());
//! })
//! .await;
//!
//! conn.on_text(|msg, handle| async move {
//! println!("Message received: {}", msg.data);
//! // Echo the message back
//! let _ = handle.send_text(&msg.data).await;
//! });
//! });
//!
//! wynd.listen(8080, || {
//! println!("Listening on port 8080");
//! })
//! .await
//! .unwrap();
//! }
//! ```
//!
//! ## Core Concepts
//!
//! - **Wynd**: The main server instance that manages connections and handles server-level events
//! - **Connection**: Represents an individual WebSocket connection with event handlers
//! - **ConnectionHandle**: Provides methods to interact with a connection (send messages, close, etc.)
//! - **Events**: Typed events for different WebSocket message types (text, binary, close, error)
//!
//! ## Examples
//!
//! See the `examples/` directory for more comprehensive examples:
//!
//! - Basic echo server
//! - Chat room implementation
//! - Binary data handling
//! - Error handling patterns
//!
//! ## Error Handling
//!
//! Wynd provides comprehensive error handling through the `WyndError` type and
//! error event handlers. All async operations return `Result` types for proper
//! error handling.
//!
//! ## Performance
//!
//! Wynd is built on Tokio's async runtime and Tungstenite's WebSocket implementation,
//! providing excellent performance for high-concurrency WebSocket applications.
//!
//! ## License
//!
//! MIT License - see LICENSE file for details.
/// WebSocket connection management and event handling.
///
/// This module provides the core connection types and event handling mechanisms
/// for managing individual WebSocket connections.
/// Internal test utilities and integration tests.
/// Event types and error definitions.
///
/// This module contains all the event types used throughout the library,
/// including message events, close events, and error types.
/// Main WebSocket server implementation.
///
/// This module contains the `Wynd` struct and related server functionality
/// for creating and managing WebSocket servers.
/// Connection handle utilities.
///
/// This module exposes [`handle::ConnectionHandle`] and helpers for interacting
/// with a live WebSocket connection (sending messages, closing, broadcasting,
/// and room operations).
/// Room management and room event types.
///
/// Provides primitives for joining/leaving rooms and broadcasting text/binary
/// messages to all members in a room.