#native #portable #web

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

#16 in WebSocket

Download history 6142/week @ 2024-12-08 6031/week @ 2024-12-15 1823/week @ 2024-12-22 3047/week @ 2024-12-29 6259/week @ 2025-01-05 7263/week @ 2025-01-12 5502/week @ 2025-01-19 4323/week @ 2025-01-26 6256/week @ 2025-02-02 3373/week @ 2025-02-09 3589/week @ 2025-02-16 4381/week @ 2025-02-23 8950/week @ 2025-03-02 13253/week @ 2025-03-09 11098/week @ 2025-03-16 9850/week @ 2025-03-23

43,319 downloads per month
Used in 51 crates (4 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–9.5MB
~74K SLoC