pub enum MockStreamEvent {
Text(String),
TextStart {
additional_params: Option<Value>,
},
TextAdditionalParams(Value),
ToolCall {
id: String,
name: String,
arguments: Value,
call_id: Option<String>,
},
ToolCallDelta {
id: String,
internal_call_id: String,
content: ToolCallDeltaContent,
},
Reasoning {
id: Option<String>,
content: ReasoningContent,
},
ReasoningDelta {
id: Option<String>,
reasoning: String,
},
MessageId(String),
FinalResponse(MockResponse),
Error(MockError),
}test-utils only.Expand description
Scripted streaming event yielded by MockCompletionModel.
Variants§
Text(String)
Text chunk.
TextStart
Start a new text content block with optional provider metadata.
TextAdditionalParams(Value)
Provider-specific metadata for the current text content block.
ToolCall
Complete tool call event.
ToolCallDelta
Tool call delta event.
Reasoning
Complete reasoning event.
ReasoningDelta
Reasoning delta event.
MessageId(String)
Provider-assigned message ID.
FinalResponse(MockResponse)
Final raw response carrying optional usage.
Error(MockError)
Stream error.
Implementations§
Source§impl MockStreamEvent
impl MockStreamEvent
Sourcepub fn text_start(additional_params: Option<Value>) -> Self
pub fn text_start(additional_params: Option<Value>) -> Self
Start a new text content block.
Sourcepub fn text_additional_params(additional_params: Value) -> Self
pub fn text_additional_params(additional_params: Value) -> Self
Add provider-specific metadata to the current text content block.
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> Self
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> Self
Create a complete tool call event.
Sourcepub fn with_call_id(self, call_id: impl Into<String>) -> Self
pub fn with_call_id(self, call_id: impl Into<String>) -> Self
Attach a provider-specific call ID to a complete tool call event.
Sourcepub fn tool_call_name_delta(
id: impl Into<String>,
internal_call_id: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn tool_call_name_delta( id: impl Into<String>, internal_call_id: impl Into<String>, name: impl Into<String>, ) -> Self
Create a tool call name delta.
Sourcepub fn tool_call_arguments_delta(
id: impl Into<String>,
internal_call_id: impl Into<String>,
arguments: impl Into<String>,
) -> Self
pub fn tool_call_arguments_delta( id: impl Into<String>, internal_call_id: impl Into<String>, arguments: impl Into<String>, ) -> Self
Create a tool call arguments delta.
Sourcepub fn with_reasoning_id(self, reasoning_id: impl Into<String>) -> Self
pub fn with_reasoning_id(self, reasoning_id: impl Into<String>) -> Self
Attach a provider-specific reasoning ID to a complete reasoning event.
Sourcepub fn reasoning_delta(
id: Option<impl Into<String>>,
reasoning: impl Into<String>,
) -> Self
pub fn reasoning_delta( id: Option<impl Into<String>>, reasoning: impl Into<String>, ) -> Self
Create a reasoning delta event.
Sourcepub fn message_id(id: impl Into<String>) -> Self
pub fn message_id(id: impl Into<String>) -> Self
Create a provider-assigned message ID event.
Sourcepub fn final_response(usage: Usage) -> Self
pub fn final_response(usage: Usage) -> Self
Create a final response event with usage.
Sourcepub fn final_response_with_default_usage() -> Self
pub fn final_response_with_default_usage() -> Self
Create a final response event with default zero usage.
Sourcepub fn final_response_with_total_tokens(total_tokens: u64) -> Self
pub fn final_response_with_total_tokens(total_tokens: u64) -> Self
Create a final response event whose usage has only total_tokens set.
Trait Implementations§
Source§impl Clone for MockStreamEvent
impl Clone for MockStreamEvent
Source§fn clone(&self) -> MockStreamEvent
fn clone(&self) -> MockStreamEvent
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 MockStreamEvent
impl RefUnwindSafe for MockStreamEvent
impl Send for MockStreamEvent
impl Sync for MockStreamEvent
impl Unpin for MockStreamEvent
impl UnsafeUnpin for MockStreamEvent
impl UnwindSafe for MockStreamEvent
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> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
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> 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