pub struct SseDecoder { /* private fields */ }Expand description
Incremental SSE frame decoder: feed raw body chunks, drain complete frames.
Tolerates CRLF, multi-line data:, and frames split across chunk
boundaries — including chunks split inside a multi-byte UTF-8 character.
Comments, id: and retry: lines are framing noise (dropped).
Implementations§
Source§impl SseDecoder
impl SseDecoder
Sourcepub fn with_limits(limits: SseLimits) -> Self
pub fn with_limits(limits: SseLimits) -> Self
Create a decoder with explicit frame and buffer limits.
Sourcepub fn push(&mut self, chunk: &[u8]) -> Result<Vec<SseFrame>, TransformError>
pub fn push(&mut self, chunk: &[u8]) -> Result<Vec<SseFrame>, TransformError>
Append a chunk and return all complete (blank-line-terminated) frames. SSE is text by definition; genuinely invalid UTF-8 is replaced lossily, while an incomplete trailing sequence waits for the next chunk.
Frames are parsed by BORROWING slices of the buffer behind an advancing
cursor; consumed bytes are drained once at the end. (The former
per-frame drain(..).collect::<String>() walked the frame char by char
AND memmoved the buffer tail per frame — the top CPU hotspot of every
streaming profile.)