pub enum StreamEvent {
Text(String),
Reasoning(ReasoningChunk),
ToolCall(ToolCall),
Status(String),
Done {
usage: Option<TokenUsage>,
provider_continuation: Option<ProviderContinuation>,
stop_reason: Option<FinishReason>,
},
}Expand description
One event emitted during a streaming model call — the adapters’ own type, re-exported rather than redefined.
This was a second enum with the same five variants, and the only thing it
added was a richer Done — which cost a translation layer that could only
fill those extra fields with None, because the adapter-side Done it
mapped from carried a bare token count. mermaid_model’s Done carries
the whole terminal payload now, so there is nothing left for a second type
to add.
A single event emitted during a streaming model call.
Exactly one Done ends a successful stream. Text and Reasoning may
interleave in any order. ToolCall events typically arrive at the end
of generation but the contract is “before Done”.
Adapters themselves never emit Done — the provider wrapper builds the
authoritative one from the returned ModelResponse, which is where the
usage and the provider continuation actually live (F3).
Variants§
Text(String)
Plain assistant content. Append to the response buffer.
Reasoning(ReasoningChunk)
Reasoning / thinking content. Render separately from regular text; renderer decides whether to display or hide based on user prefs.
ToolCall(ToolCall)
A tool/function call extracted from the model response.
Status(String)
Out-of-band, user-visible plumbing notice (e.g. “Starting the local
Ollama server…”). NOT response content: surfaces as a transient /
system line, never appended to the assistant message. May arrive
before any Text.
Done
Stream complete. Carries final token usage (None when the provider
never reported any, so the reducer keeps its estimate rather than
resetting the gauge to zero), any opaque provider continuation state
to round-trip on the next request, and why generation stopped (so the
reducer can flag truncation or a content block).
Fields
usage: Option<TokenUsage>provider_continuation: Option<ProviderContinuation>stop_reason: Option<FinishReason>Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§fn clone(&self) -> StreamEvent
fn clone(&self) -> StreamEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StreamEvent
impl RefUnwindSafe for StreamEvent
impl Send for StreamEvent
impl Sync for StreamEvent
impl Unpin for StreamEvent
impl UnsafeUnpin for StreamEvent
impl UnwindSafe for StreamEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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