#websocket-client #web-native #web #native #portable

ewebsock

WebSocket client that works natively and on the web (WASM)

9 releases (breaking)

0.8.0 Nov 11, 2024
0.6.0 May 21, 2024
0.5.0 Feb 26, 2024
0.4.0 Oct 7, 2023
0.1.0 Feb 23, 2022

#85 in WebSocket

Download history 1917/week @ 2025-10-12 2631/week @ 2025-10-19 2106/week @ 2025-10-26 3129/week @ 2025-11-02 2510/week @ 2025-11-09 2189/week @ 2025-11-16 2400/week @ 2025-11-23 2011/week @ 2025-11-30 1857/week @ 2025-12-07 1707/week @ 2025-12-14 1130/week @ 2025-12-21 1684/week @ 2025-12-28 2077/week @ 2026-01-04 2165/week @ 2026-01-11 2466/week @ 2026-01-18 2029/week @ 2026-01-25

8,940 downloads per month
Used in 31 crates (7 directly)

MIT/Apache

43KB
667 lines

ewebsock

github Latest version Documentation unsafe forbidden Build Status MIT Apache

This is a simple WebSocket library for Rust which can be compiled to both native and web (WASM).

Usage

let options = ewebsock::Options::default();
// see documentation for more options
let (mut sender, receiver) = ewebsock::connect("ws://example.com", options).unwrap();
sender.send(ewebsock::WsMessage::Text("Hello!".into()));
while let Some(event) = receiver.try_recv() {
    println!("Received {:?}", event);
}

Testing

First start the example echo server with:

cargo r -p echo_server

Then test the library with:

# native mode
cargo run -p example_app

# web mode
# install trunk with `cargo install trunk` - https://trunkrs.dev/
(cd example_app && trunk serve)

Dependencies

~0.2–3.5MB
~62K SLoC