Expand description
WebSocket helpers for endpoints that stream events over a persistent
connection (e.g. /api/v1/notifications/stream).
Built on tokio_tungstenite with rustls + webpki roots so it works out
of the box against TLS deployments. Exposes a futures::Stream of
parsed JSON events — callers decide how to handle each one.
§Example
use futures::StreamExt;
use nucel_sdk_api::ws::{NotificationStreamEvent, stream_notifications};
let mut events = stream_notifications("https://nucel.dev", "ghp_token").await?;
while let Some(Ok(ev)) = events.next().await {
match ev {
NotificationStreamEvent::Init { unread_count } => {
println!("connected, {unread_count} unread");
}
NotificationStreamEvent::Other(v) => {
println!("event: {v}");
}
}
}Enums§
- Notification
Stream Event - An event on the notification stream.
- WsError
- Errors the WebSocket stream can produce.
Functions§
- build_
ws_ url - Turn
http(s)://host[:port]+ a path into aws(s)://host[:port]/path?token=.... - stream_
notifications - Open a WebSocket to
/api/v1/notifications/streamand return a stream of parsed events. Thetokenis sent as both anAuthorization: Bearerheader AND a?token=query param so the call works against any server config.