Skip to main content

ChatStream

Type Alias ChatStream 

Source
pub type ChatStream = Pin<Box<dyn Stream<Item = Result<ChatStreamEvent, InferenceError>> + Send>>;
Expand description

The boxed, Send stream of streaming events an adapter yields.

Why: async fn chat_stream is dispatched through Box<dyn InferenceAdapter>, so its item stream must be object-safe โ€” a concrete impl Stream cannot cross the trait boundary. Boxing + pinning erases the provider-specific stream type while keeping it pollable and shareable across tokio tasks (Send). What: a pinned, heap-boxed Stream yielding Result<ChatStreamEvent, InferenceError> โ€” ordered text/tool deltas followed by exactly one terminal ChatStreamEvent::Done (unless the transport errors mid-stream, which surfaces as a terminal Err). Test: decode_yields_deltas_then_done.

Aliased Typeยง

#[repr(transparent)]
pub struct ChatStream { /* private fields */ }