Repository navigation
v0.5.1 -- WebSocket source + sink
New: WebSocket source + sink in pipe-http
Bidirectional WebSocket communication via pipe_http::ws.
use pipe_http::ws;
let (incoming, sender) = ws::connect("wss://example.com/ws");
// Send from any task
let s = sender.clone();
tokio::spawn(async move { s.send_text("hello").await });
// Process incoming as a pipe
incoming
.and_then(|m| m.text())
.for_each(|text| println!("{text}"))
.await?;Features
ws::connect(url)-- returns(Pipe<WsMessage>, WsSender)synchronously; connection established lazily on first pullWsSender-- cloneable, channel-based write handle decoupled from pong responsesWsMessage-- Text, Binary, Close variants withOption-returningtext()andbytes()accessors- Automatic ping/pong handling (transparent to user)
- 16 MiB incoming message size limit
- Sender detects closed connection (
PipeError::Closed) - 8 integration tests against in-process axum WebSocket server
No auto-reconnection by design
WebSocket has no built-in resume protocol (unlike SSE's Last-Event-ID). For app-level reconnection, use pipe's retry() or handle_error_with().
Install
[dependencies]
pipe-http = { git = "https://github.com/hamidr/pipe" }263 total workspace tests, zero warnings.