gglib_core/sse/
mod.rs

1//! Server-Sent Events (SSE) codec for `OpenAI`-compatible chat completion
2//! streams.
3//!
4//! This module is the **single source of truth** for translating between
5//! the `OpenAI` `chat.completion.chunk` SSE wire format and the typed
6//! [`crate::LlmStreamEvent`] domain values.  It contains three pieces:
7//!
8//! | Submodule | Role |
9//! |-----------|------|
10//! | [`parser`] | Parse one `data:` JSON payload → typed events |
11//! | [`decoder`] | Stateful byte-stream → events (line buffering, `[DONE]`) |
12//! | [`encoder`] | Typed event → `data:` JSON payload (for re-emission) |
13//!
14//! Promoting the codec to `gglib-core` lets every adapter (runtime, proxy,
15//! future GUIs) share a single, well-tested implementation rather than
16//! re-rolling SSE parsing per surface.
17
18pub mod decoder;
19pub mod encoder;
20pub mod parser;
21
22pub use decoder::SseStreamDecoder;
23pub use encoder::SseEncoder;
24pub use parser::{SseParseResult, parse_sse_frame};