#browser #async-api #data-exchange #desktop-applications #rpc #client-server #server-api

workflow-websocket

WebSocket crate (client and server) providing an async Rust API that functions uniformly in native and in browser (WASM32) environments. This crate allows you to develop WebSocket-driven data exchange that function uniformly in web and desktop applications.

38 releases (15 breaking)

0.18.0 Sep 7, 2024
0.15.0 Jul 26, 2024
0.11.0 Feb 25, 2024
0.10.2 Dec 24, 2023
0.1.2 Sep 21, 2022

#26 in WebSocket

Download history 687/week @ 2024-08-19 660/week @ 2024-08-26 1276/week @ 2024-09-02 974/week @ 2024-09-09 464/week @ 2024-09-16 518/week @ 2024-09-23 507/week @ 2024-09-30 410/week @ 2024-10-07 693/week @ 2024-10-14 590/week @ 2024-10-21 506/week @ 2024-10-28 258/week @ 2024-11-04 672/week @ 2024-11-11 644/week @ 2024-11-18 348/week @ 2024-11-25 374/week @ 2024-12-02

2,067 downloads per month
Used in 17 crates (2 directly)

MIT/Apache

345KB
7K SLoC

workflow-websocket

Part of the workflow-rs application framework.


github crates.io docs.rs license

Platform-neutral WebSocket Client and native Server.

Features

  • Uniform async Rust WebSocket client API that functions in the browser environment (backed by browser WebSocket class) as well as on native platforms (backed by Tungstenite client).
  • Trait-based WebSocket server API backed by Tungstenite server.

This crate allows you to develop a WebSocket client that will work uniformly in in hte native environment and in-browser.

Workflow-WebSocket crate is currently (as of Q3 2022) one of the few available async Rust client-side in-browser WebSocket implementations.

This web socket crate offers an async message send API as well as provides access to Receiver and Sender async_std channels ([async_channel])(https://docs.rs/async-channel/latest/async_channel/) that can be used to send and receive WebSocket messages asynchronously.

To use workflow-websocket in the Node.js environment, you need to introduce a W3C WebSocket object before loading the WASM32 library to simulate the global WebSocket object available in Web Browsers. The WebSocket NPM module provides W3C WebSocket compatible implementation and can be used as follows:

// WebSocket
globalThis.WebSocket = require('websocket').w3cwebsocket;
// Load WASM32 library ...

Dependencies

~17–33MB
~526K SLoC