pub enum StreamChunk {
TextDelta(String),
ThinkingDelta(String),
ToolCallReady(ToolCall),
ToolCalls(Vec<ToolCall>),
Done(TokenUsage),
NetworkError(String),
}Expand description
A streaming chunk from the LLM.
Variants§
TextDelta(String)
A text delta (partial content).
ThinkingDelta(String)
A thinking/reasoning delta from native API (Anthropic extended thinking, OpenAI reasoning).
ToolCallReady(ToolCall)
A single tool call whose arguments finished streaming.
Emitted by providers that support per-block completion events (Anthropic
content_block_stop). Enables eager execution of read-only tools while
subsequent tool calls are still being streamed.
Providers that don’t support per-block events (OpenAI, Gemini) never
emit this — they only emit ToolCalls at stream end.
ToolCalls(Vec<ToolCall>)
All tool calls from the response (batch, emitted at stream end).
For Anthropic, this only contains tool calls NOT already emitted via
ToolCallReady. For other providers, this contains all tool calls.
Done(TokenUsage)
Stream finished with usage info.
NetworkError(String)
The underlying HTTP connection was dropped before the stream completed.
Distinct from Done (clean finish) and user-initiated cancellation
(Ctrl+C). The partial response MUST be discarded — it is incomplete
and storing it would corrupt the session history on resume.
Trait Implementations§
Source§impl Clone for StreamChunk
impl Clone for StreamChunk
Source§fn clone(&self) -> StreamChunk
fn clone(&self) -> StreamChunk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StreamChunk
impl RefUnwindSafe for StreamChunk
impl Send for StreamChunk
impl Sync for StreamChunk
impl Unpin for StreamChunk
impl UnsafeUnpin for StreamChunk
impl UnwindSafe for StreamChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more