Files
Windows-Gotify-Client-Rust/Cargo.toml
T
KennethCheng 319eeb44ae feat(gotify): Phase 4 C1 — WebSocket reconnect + 帧解析
- src/gotify/reconnect.rs: ReconnectPolicy 按 §15 退避序列
  1s/2s/4s/8s/16s/30s...record_success() 重置;inline #[cfg(test)]
  3 个 backoff 测试
- src/gotify/websocket.rs: blocking tungstenite 0.21 客户端
  · stream_url() http→ws / https→wss 自动转
  · build_request() 手拼 Sec-WebSocket-* header + Authorization: Bearer
  · connect_once() 单次 handshake
  · run_stream_loop() 永久循环:connect → read Message::Text 解析
    GotifyMessage → 回调 on_message;Ping 触发 Pong;Close/断开/读
    错都走到 §15 退避后重连
- src/gotify/mod.rs: re-export 加 reconnect + websocket 子模块
- Cargo.toml: tungstenite 0.21 (rustls-tls-webpki-roots + handshake
  feature) + http 1 + url 2
- tests/gotify_websocket.rs: 3 个 JSON envelope 解析测试

避坑:
- tungstenite 0.21 的 connect 在 handshake feature 后(默认不带),要
  显式开
- WebSocketConfig 0.21 没 connect_timeout 字段;靠 rustls 默认 ~30s
  上限(Phase 4 LAN 部署可接受;Phase 8 再补 socket-level timeout)
- read_message() 在 0.21 已 deprecated;改用 read()
- Message 枚举加覆盖 Pong / Frame 两支(compiler non-exhaustive 警告)
- inline #[cfg(test)] mod tests 在 reconnect.rs 跑 unit tests(与
  tests/ 集成测试并列)

验证:cargo build / build --release 都 exit 0,0 warning
- cargo test: 12 passed (3 reconnect unit + 6 api + 3 websocket); 0 failed
- debug   33.36 MB, subsystem = WINDOWS_CUI
- release  9.43 MB, subsystem = WINDOWS_GUI(tungstenite + http 在 LTO
  后几乎不增体积——和 Phase 3 C2 持平)
2026-09-19 06:00:40 +08:00

67 lines
2.2 KiB
TOML

# Cargo.toml — Phase 1 (Bootstrap).
#
# Dependency rationale lives in AGENTS.md §44. Only the crates actually used
# by Phase 1 are listed; the remaining crates (reqwest / tungstenite / serde /
# url / anyhow / ...) are added in later phases when their modules land.
[package]
name = "windows-gotify-client-rust"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
description = "Lightweight, modern, Windows-native Gotify desktop client (Rust + Slint)"
license = "MIT"
readme = "README.md"
authors = ["KennethCheng <a1478925630@163.com>"]
[[bin]]
name = "windows-gotify-client-rust"
path = "src/main.rs"
[dependencies]
# --- UI ---
# `slint` crate. The `slint!{}` macro is compiled in via the default feature
# set in 1.x (verified against 1.18.0 — `internal-interpreter` was removed in
# 1.x). The Windows GUI backend (`backend-winit`) is also part of defaults.
# Phase 2 will likely switch from the embedded macro to `include_slint!()`
# + standalone .slint files under `ui/`.
slint = "1"
# --- Logging ---
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# --- Error handling ---
thiserror = "2"
# --- Serialization (Phase 2 C3 storage) ---
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# --- Networking (Phase 3 Gotify HTTP) ---
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
# --- Date/time (Phase 3 C2 convert Gotify RFC3339) ---
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
# --- WebSocket (Phase 4 real-time stream) ---
tungstenite = { version = "0.21", default-features = false, features = ["rustls-tls-webpki-roots", "handshake"] }
url = "2"
http = "1"
# Slint's `.slint` files are compiled by `build.rs`; see build.rs.
[build-dependencies]
slint-build = "1"
[profile.release]
# See AGENTS.md §42. The `release-balanced` profile below is the practical
# default after benchmarking — adjust if startup time regresses.
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
strip = true
[profile.release-balanced]
inherits = "release"
opt-level = 3