Skip to main content

Module ws

Module ws 

Source
Expand description

Slim WebSocket subscriber for the relay’s /ws endpoint.

Phase 5 ships this for cinch pull --watch. It is intentionally narrower than desktop/src-tauri/src/ws.rs (which still owns its tauri-coupled lifecycle, tray status, db inserts, image fetch, and key-exchange responder). Once that desktop logic gets refactored to consume callbacks from this module, the duplicated reconnect/decrypt plumbing inside desktop’s ws.rs can shrink to a thin event bridge.

The client connects with bearer-token auth via the URL query string (?token=...), reads frames, decodes WSMessage, decrypts clip content when encrypted=true, and forwards every interesting message through an mpsc::Sender<WsEvent> provided by the caller.

Structs§

WsConfig

Enums§

DecryptFailReason
DecryptOutcome
Outcome of a single decrypt attempt on an incoming clip.
WsError
WsEvent
WsStatus

Functions§

decrypt_clip_content
Decrypt clip.content in place if clip.encrypted and a key is available. Returns a typed outcome — never silently returns ciphertext as plaintext.
run
Connect to the relay and forward decoded events to tx until the caller drops the receiver. Reconnects on socket error with exponential backoff (1s, 2s, 4s … capped at 30s). Returns when tx is closed.