Wynd
A simple, fast, and developer-friendly WebSocket library for Rust.
Features
- 🚀 Simple API: Easy-to-use event-driven API with async/await support
- ⚡ High Performance: Built on Tokio for excellent async performance
- 🛡️ Type Safety: Strongly typed message events and error handling
- 🔧 Developer Experience: Comprehensive documentation and examples
- 🔄 Connection Management: Automatic connection lifecycle management
- 📡 Real-time Ready: Perfect for chat apps, games, and live dashboards
Quick Start
Add Wynd to your Cargo.toml:
[]
= "0.3"
= { = "1.0", = ["macros", "rt-multi-thread"] }
Create a simple echo server:
use Wynd;
async
Examples
Chat Room Server
use Wynd;
use HashMap;
use Arc;
use Mutex;
async
async
Documentation
- Getting Started - Quick setup and first steps
- API Reference - Complete API documentation
- Examples - Practical examples and use cases
- Tutorial - Step-by-step guide to building a chat server
- Guides - Best practices and advanced patterns
Core Concepts
Wynd Server
The main server instance that manages connections and handles server-level events.
Connection
Represents an individual WebSocket connection with event handlers for different message types.
ConnectionHandle
Provides methods to interact with a connection (send messages, close, etc.).
Events
Typed events for different WebSocket message types:
TextMessageEvent- UTF-8 text messagesBinaryMessageEvent- Binary dataCloseEvent- Connection closure with code and reasonWyndError- Server-level errors
Testing
Test your WebSocket server using any WebSocket client:
Using wscat
# Install wscat
# Connect to your server
# Send messages
Using a Web Browser
const ws = ;
ws ;
ws ;
Performance
Wynd is built for high-performance WebSocket applications:
- Async by Design: Full async/await support with Tokio runtime
- Concurrent Connections: Each connection runs in its own task
- Efficient Message Handling: Minimal overhead for message processing
- Memory Efficient: Smart connection management and cleanup
Error Handling
Wynd provides comprehensive error handling:
// Handle send errors
match handle.send_text.await
// Handle server errors
wynd.on_error;
// Handle connection errors
conn.on_close;
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built on top of Tokio for async runtime
- Uses Tungstenite for WebSocket protocol handling
- Inspired by the need for a simple, developer-friendly WebSocket library in Rust