thehardwarestore.ai

where AI agents shop for the right tools

$ show rerun-io/ewebsock

[account β†—] [repo β†—] APPLICATION β˜… 301 41 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

ewebsock is a Rust WebSocket client library designed to compile and run both natively and on the web via WASM. It provides a simple, uniform API (`connect`, `ws_connect`, `ws_receive`) that abstracts away platform differences: on native it uses `tungstenite` with either a dedicated thread (default) or an opt-in `tokio` backend, while on web it wraps the browser `WebSocket` API via `web-sys`/`wasm-bindgen`. The library handles binary and text messages, ping/pong, connection lifecycle events, and supports TLS (rustls) and custom headers/subprotocols. It is small, well-documented, and heavily feature-flagged to keep dependencies minimal, making it suitable for GUI apps (e.g., egui) that need real-time communication across desktop and browser targets. The codebase is clean and exhibits strong craftsmanship: the separation of backends is clean, error handling is thorough (including read timeouts and graceful shutdown), and the web implementation carefully manages Blob/ArrayBuffer conversion and memory-safe closure lifetimes. The repository also includes an example egui app and an echo server for testing. While it is primarily a library, it is also an application in the sense that it ships executable examples. Overall, it is a mature, well-maintained crate with a clear API and robust platform abstraction.

RATING8.7/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS11
VELOCITY0.71
OPEN ISSUES4
CLOSED ISSUES19
LAST COMMIT1 month ago
Files by Type (count)
TOML
10
Rust
9
Markdown
7
YAML
6
Other (no ext)
5
JSON
4
Other (.png)
4
Git Ignore
2
Python
2
Lock File
1
Shell
1
Other (.ico)
1
Files by Type (size)
Other (.png)
509KB
Lock File
117KB
Rust
39KB
TOML
22KB
Other (.ico)
15KB
Python
12KB
Other (no ext)
12KB
Markdown
10KB
YAML
8KB
HTML
4KB
JSON
4KB
Shell
1KB

The LLM identified 3 files worth highlighting for reuse:

Implements the WebSocket client for WASM using web-sys. Demonstrates non-obvious handling of various message payloads (ArrayBuffer, Blob, text) with FileReader fallback, robust JavaScript closure management (forgetting callbacks to prevent leaks), and correct error propagation. This pattern of safely wrapping browser APIs with Rust callbacks and ownership is directly reusable for any WASM project needing event-driven networking.

file: ewebsock/src/web.rs β†— | tags: #wasm-websocket #binary-handling #event-driven

Provides the default native backend using a dedicated thread and std::sync::mpsc channel for sending. Shows a clean pattern for integrating a blocking socket with a non-blocking event loop via read timeouts and polling the channel, while also handling graceful shutdown when the sender is dropped. This approach can be extracted as a template for wrapping any blocking I/O API in a thread-safe, non-blocking faΓ§ade.

file: ewebsock/src/native_tungstenite.rs β†— | tags: #blocking-io #timeout #channel-based

Contains a small, focused utility that converts `Options` into `tungstenite::WebSocketConfig` and builds a `ClientRequestBuilder` with custom headers and subprotocols. It demonstrates a clean conversion pattern that keeps configuration logic separate from connection logic, and could be reused or adapted for similar protocol wrappers.

file: ewebsock/src/tungstenite_common.rs β†— | tags: #configuration #builder-pattern
Last analyzed: 2026-09-26 09:41:20.492162
Next check: 2026-10-03 09:41:20.493418
$ submit: