wynd 0.4.4

A simple websocket library for rust.
Documentation

Wynd

A simple, fast, and developer-friendly WebSocket library for Rust.

Crates.io Documentation License

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
  • 🌐 HTTP Integration: Optional ripress integration for combined HTTP + WebSocket servers

Quick Start

Add Wynd to your Cargo.toml:

[dependencies]
wynd = "0.3"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

Create a simple echo server:

use wynd::wynd::{Wynd, Standalone};

#[tokio::main]
async fn main() {
    let mut wynd: Wynd<Standalone> = Wynd::new();

    wynd.on_connection(|conn| async move {
        conn.on_text(|msg, handle| async move {
            let _ = handle.send_text(&format!("Echo: {}", msg.data)).await;
        });
    });

    wynd.listen(8080, || {
        println!("Server listening on ws://localhost:8080");
    })
    .await
    .unwrap();
}

HTTP + WebSocket Integration

Use the with-ripress feature to serve both HTTP and WebSocket on the same port:

use ripress::{app::App, types::RouterFns};
use wynd::wynd::{Wynd, WithRipress};

#[tokio::main]
async fn main() {
    let mut wynd: Wynd<WithRipress> = Wynd::new();
    let mut app = App::new();

    wynd.on_connection(|conn| async move {
        conn.on_text(|event, handle| async move {
            let _ = handle.send_text(&format!("Echo: {}", event.data)).await;
        });
    });

    app.get("/", |_, res| async move { res.ok().text("Hello World!") });
    app.use_wynd("/ws", wynd.handler());

    app.listen(3000, || {
        println!("Server running on http://localhost:3000");
        println!("WebSocket available at ws://localhost:3000/ws");
    })
    .await;
}

Documentation

Performance

  • 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

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.