#websocket #框架 #Web 框架 #web #http

axum-tungstenite

使用 tungstenite 直接为 axum 创建 WebSocket 连接

4 个版本 (2 个重大更新)

0.3.0 2023 年 8 月 2 日
0.2.0 2022 年 12 月 10 日
0.1.1 2022 年 11 月 17 日
0.1.0 2022 年 5 月 15 日

#236#websocket

Download history 347/week @ 2024-03-13 329/week @ 2024-03-20 311/week @ 2024-03-27 273/week @ 2024-04-03 369/week @ 2024-04-10 401/week @ 2024-04-17 312/week @ 2024-04-24 215/week @ 2024-05-01 216/week @ 2024-05-08 258/week @ 2024-05-15 287/week @ 2024-05-22 313/week @ 2024-05-29 180/week @ 2024-06-05 326/week @ 2024-06-12 299/week @ 2024-06-19 171/week @ 2024-06-26

1,029 每月下载量

MIT 许可证

25KB
419 代码行

axum-tungstenite

使用 tungstenite 直接为 axum 创建 WebSocket 连接。

CI Crates.io Documentation

有关此包的更多信息,请参阅 包文档

axum::extract::ws 的区别

axum 已经通过 axum::extract::ws 支持 WebSockets。然而,axum 在底层使用 tungstenite 是一个私有实现细节。因此,axum 不直接公开 tungstenite 的类型,如 tungstenite::Errortungstenite::Message。这使得 axum 可以在 axum 的新小版本中更新到 tungstenite 的新主要版本,从而提高了 API 的稳定性。

此库以不同的方式工作,它在其公共 API 中直接使用 tungstenite 的类型。这使得一些事情变得更简单,但也意味着当 tungstenite 更新时,axum-tungstenite 也将收到一个新的主要版本。

您应该选择哪个?

默认情况下,除非您需要 tungstenite 的特定功能并且不介意跟进额外的重大更改,否则您应该使用 axum::extract::ws

安全性

此包使用 #![forbid(unsafe_code)] 确保所有内容都在 100% 安全的 Rust 中实现。

许可证

本项目采用 MIT 许可证

依赖项

~5.5–8MB
~139K SLoC