#websocket #framework #web-framework #web #http

axum-tungstenite

WebSocket connections for axum directly using tungstenite

4 releases (2 breaking)

0.3.0 Aug 2, 2023
0.2.0 Dec 10, 2022
0.1.1 Nov 17, 2022
0.1.0 May 15, 2022

#235 in #websocket

Download history 986/week @ 2023-12-13 507/week @ 2023-12-20 128/week @ 2023-12-27 224/week @ 2024-01-03 161/week @ 2024-01-10 241/week @ 2024-01-17 267/week @ 2024-01-24 217/week @ 2024-01-31 287/week @ 2024-02-07 277/week @ 2024-02-14 233/week @ 2024-02-21 292/week @ 2024-02-28 350/week @ 2024-03-06 347/week @ 2024-03-13 334/week @ 2024-03-20 294/week @ 2024-03-27

1,423 downloads per month

MIT license

25KB
419 lines

axum-tungstenite

WebSocket connections for axum directly using tungstenite.

CI Crates.io Documentation

More information about this crate can be found in the crate documentation.

Differences from axum::extract::ws

axum already supports WebSockets through axum::extract::ws. However the fact that axum uses tungstenite under the hood is a private implementation detail. Thus axum doesn't directly expose types from tungstenite, such as tungstenite::Error and tungstenite::Message. This allows axum to update to a new major version of tungstenite in a new minor version of axum, which leads to greater API stability.

This library works differently as it directly uses the types from tungstenite in its public API. That makes some things simpler but also means axum-tungstenite will receive a new major version when tungstenite does.

Which should you choose?

By default you should use axum::extract::ws unless you specifically need something from tungstenite and don't mind keeping up with additional breaking changes.

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

License

This project is licensed under the MIT license.

Dependencies

~5.5–8MB
~139K SLoC