pub enum ChatStreamEvent {
Delta(String),
ToolCall(ToolCallDelta),
Done(StreamCompletion),
}Expand description
One event in a streamed chat completion.
Why: consumers render as tokens arrive and must also receive the authoritative
finish reason + usage the non-streaming path returns — so the stream carries
both incremental fragments and a single terminal summary rather than forcing
the caller to reconstruct usage from raw chunks.
What: Self::Delta is a text-content fragment (append in order);
Self::ToolCall is a streamed tool-call fragment (accumulate by index);
Self::Done is the terminal event carrying the finish reason and usage.
Exactly one Done ends a healthy stream, and it is always the last item.
Test: decode_yields_deltas_then_done, decode_accumulates_tool_call.
Variants§
Delta(String)
An incremental assistant text fragment, in emission order.
ToolCall(ToolCallDelta)
A streamed tool-call fragment (OpenAI streams calls across frames).
Done(StreamCompletion)
Terminal event: the model finished; carries the finish reason + usage.
Trait Implementations§
Source§impl Clone for ChatStreamEvent
impl Clone for ChatStreamEvent
Source§fn clone(&self) -> ChatStreamEvent
fn clone(&self) -> ChatStreamEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChatStreamEvent
impl Debug for ChatStreamEvent
Source§impl PartialEq for ChatStreamEvent
impl PartialEq for ChatStreamEvent
impl StructuralPartialEq for ChatStreamEvent
Auto Trait Implementations§
impl Freeze for ChatStreamEvent
impl RefUnwindSafe for ChatStreamEvent
impl Send for ChatStreamEvent
impl Sync for ChatStreamEvent
impl Unpin for ChatStreamEvent
impl UnsafeUnpin for ChatStreamEvent
impl UnwindSafe for ChatStreamEvent
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