Skip to main content

decode_stream

Function decode_stream 

Source
pub fn decode_stream<S>(
    bytes: S,
    source: WireFormat,
) -> Result<LlmResponseStream, LlmClientError>
where S: Stream<Item = Result<Vec<u8>, LlmClientError>> + Send + 'static,
Expand description

Decodes provider SSE bytes into normalized stream events.

Operates on raw bytes, not any HTTP client type: the caller adapts its transport’s body stream into Stream<Item = Result<Vec<u8>, _>>. Frames are buffered across chunks (a partial frame waits for its boundary); the source stream codec is resolved once and reused for every frame.

The decoder tracks the source format’s protocol-specific terminal event. If EOF arrives without that required event, the stream yields a deferred [LlmClientError::ResponseTranslation] error after any valid decoded events.