Expand description
SseLines: a minimal Server-Sent-Events line pump over a
reqwest::Response body (issue #3415).
Why: CodeEngine consumes two SSE routes
(GET /sessions/{id}/events, GET /workstreams/{id}/events) that both
frame their payloads as plain data: <json>\n\n lines (axum’s
axum::response::sse::Event::default().json_data(..), see
crate::serve::http::sse_event_for/crate::workstreams::sse::sse_event_for).
Pulling in a full SSE client crate for “read data: lines from a byte
stream” would be disproportionate; crate::cli_client::stdio already
shows this crate’s convention of hand-rolling the minimal wire parser
for a trusted, in-house transport rather than adding a dependency for a
few lines of line-splitting (mirrors
trusty_common::chat::openai_compat::sse_pump::pump_openai_sse’s
buf.find('\n') loop, adapted to this crate’s own data: framing).
What: SseLines::new wraps a reqwest::Response’s byte stream;
SseLines::next_data returns the next non-empty data: payload
(already stripped of the prefix and trimmed) as Ok(Some(json_text)),
Ok(None) on a clean upstream close, or Err on a stream I/O failure.
SSE comment lines (: keep-alive pings) and blank data: lines are
silently skipped, never surfaced.
Test: sse_tests::* against synthetic byte chunks (no network).
Structs§
- SseLines
- See module docs.