10 unstable releases (4 breaking)

new 0.5.1 Mar 17, 2023
0.5.0 Mar 17, 2023
0.4.4 Mar 17, 2023
0.4.0 Nov 29, 2022
0.1.0 Mar 23, 2022

#25 in WebSocket

Download history 46/week @ 2022-11-28 36/week @ 2022-12-05 34/week @ 2022-12-12 11/week @ 2022-12-19 26/week @ 2022-12-26 25/week @ 2023-01-02 16/week @ 2023-01-09 48/week @ 2023-01-16 90/week @ 2023-01-23 28/week @ 2023-01-30 132/week @ 2023-02-06 79/week @ 2023-02-13 123/week @ 2023-02-20 168/week @ 2023-02-27 118/week @ 2023-03-06 181/week @ 2023-03-13

590 downloads per month

MIT license

63KB
1K SLoC

ezsockets

Creating a WebSocket server or a client in Rust can be troublesome. This crate facilitates this process by providing:

  • Traits to allow declarative and event-based programming.
  • Easy concurrency with Tokio and async/await. Server sessions are Clone'able and can be shared between tasks.
  • Heartbeat mechanism to keep the connection alive.
  • Automatic reconnection of WebSocket Client.
  • Support for multiple back-ends such as Axum or Tungstenite.
  • TLS support for servers with rustls and native-tls.

Documentation

View the full documentation at docs.rs/ezsockets

Examples

  • simple-client - a simplest WebSocket client which uses stdin as input.
  • echo-server - server that echoes back every message it receives.
  • echo-server - same as echo-server, but with native-tls.
  • counter-server - server that increments global value every second and shares it with client
  • chat-client - chat client for chat-server and chat-server-axum examples
  • chat-server - chat server with support of rooms
  • chat-server-axum - same as above, but using axum as a back-end

Client

tokio-tungstenite is being used under the hood.

See examples/simple-client for a simple usage and docs.rs/ezsockets/server for documentation.

Server

WebSocket server can use one of supported back-ends:

  • tokio-tungstenite - the simplest way to get started.
  • axum - ergonomic and modular web framework built with Tokio, Tower, and Hyper
  • actix-web - Work in progress at #22

See examples/echo-server for a simple usage and docs.rs/ezsockets/server for documentation.

Dependencies

~6–14MB
~288K SLoC