reinhardt-websockets

Crates.ioreinhardt-websockets
lib.rsreinhardt-websockets
version0.1.0-alpha.1
created_at2026-01-23 10:14:42.673553+00
updated_at2026-01-23 10:14:42.673553+00
descriptionWebSocket support for real-time bidirectional communication
homepage
repositoryhttps://github.com/kent8192/reinhardt-rs
max_upload_size
id2064028
size405,596
kento (kent8192)

documentation

README

reinhardt-websockets

WebSocket support for the Reinhardt framework.

Overview

WebSocket protocol support for real-time bidirectional communication. Includes connection management, message routing, room management, and WebSocket handler traits for building interactive applications.

Installation

Add reinhardt to your Cargo.toml:

[dependencies]
reinhardt = { version = "0.1.0-alpha.1", features = ["websockets"] }

# Or use a preset:
# reinhardt = { version = "0.1.0-alpha.1", features = ["standard"] }  # Recommended
# reinhardt = { version = "0.1.0-alpha.1", features = ["full"] }      # All features

Then import WebSocket features:

use reinhardt::websockets::{WebSocketConnection, WebSocketHandler, Message};
use reinhardt::websockets::{RoomManager, WebSocketMessage};

Note: WebSocket features are included in the standard and full feature presets.

Features

Implemented ✓

Connection Management

  • WebSocketConnection: Manages individual WebSocket connections
    • Connection ID tracking
    • Send text, binary, and JSON messages
    • Connection state management (open/closed)
    • Async message sending with error handling
  • WebSocketError and WebSocketResult: Comprehensive error handling
    • Connection errors
    • Send/receive errors
    • Protocol errors

Message Types

  • Message enum: Multiple message types support
    • Text messages
    • Binary messages
    • Ping/Pong messages
    • Close messages with status codes
    • JSON serialization/deserialization helpers
  • WebSocketMessage struct: Structured message format with timestamps
    • Message type classification
    • JSON data payload
    • Optional timestamp support

Room Management

  • RoomManager: Multi-client room management
    • Join/leave room operations
    • Broadcast messages to specific rooms
    • Broadcast messages to all rooms
    • Room size tracking
    • List all active rooms
    • Thread-safe with async/await support

Handler Traits

  • WebSocketHandler: Trait for implementing custom WebSocket handlers
    • on_message: Handle incoming messages
    • on_connect: Handle new connections
    • on_disconnect: Handle disconnections
Commit count: 2845

cargo fmt