RustWave is a lightweight asynchronous WebSocket framework for Rust that provides a clean, event-driven API for building real-time applications. Built on Tokio, RustWave offers namespaces, rooms, broadcasting, and typed payloads while keeping the API simple and ergonomic.
Features
- Async WebSocket server & client
- Event-driven API
- Namespaces
- Rooms
- Broadcasting
- Typed payload parsing
- Built on Tokio
- Simple and ergonomic API
Why RustWave?
- Simple event-driven API
- Built on Tokio
- Typed payload parsing
- Namespaces and rooms
- Minimal dependencies
- Easy to integrate into existing projects
Installation
Add RustWave to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
Server
use ;
async
Client
use ;
async
Examples
For a complete example, see the examples directory.
API Overview
| Type | Responsibility |
|---|---|
Server |
Binds to an address, manages namespaces, accepts incoming connections |
Namespace |
Isolated event/room registry for a specific path (e.g. /chat) |
Client |
Connects to a RustWave server and exchanges events |
PeerContext |
Handle for a connected socket — emit, broadcast, join/leave rooms |
Payload |
Wraps incoming event data, parseable into any Deserialize type |
Benchmark
Test Environment
- CPU: Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
- RAM: 4 GB
- OS: Fedora Linux
- Rust: 1.94.0
- Build:
cargo run --release
Echo Benchmark
| Metric | Value |
|---|---|
| Concurrent clients | 10,000 |
| Messages per client | 100 |
| Total messages | 1,000,000 |
| Message loss | 0 |
| Total time | 8.88 s |
| Throughput | 112,587 msgs/sec |
Roadmap
- Event-driven API
- Async WebSocket server
- Async WebSocket client
- Rooms
- Namespaces
- Broadcasting
- Broadcast except sender
- Typed payload parsing
- Client disconnection
- Multiple event handlers
- Middleware support
- Authentication hooks
- Automatic reconnection for clients
- Binary message support
- Configurable heartbeat (Ping/Pong)
- Request/response acknowledgements (ACKs)
- Custom serializer support
- Connection metadata
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License.