pub enum MockStreamEvent {
Show 14 variants
Text(String),
TextStart {
id: String,
additional_params: Option<Value>,
},
TextAdditionalParams(Value),
ToolCall {
id: String,
name: String,
arguments: Value,
call_id: Option<String>,
},
ToolCallNameDelta {
id: String,
name: String,
},
ToolCallArgumentsDelta {
id: String,
arguments: String,
},
ToolCallEnd {
id: String,
},
Reasoning {
id: String,
content: ReasoningContent,
},
ReasoningDelta {
id: String,
reasoning: String,
},
MessageId(String),
Unknown(Value),
RequestId(String),
FinalResponse(Finish),
Error(MockError),
}test-utils only.Expand description
Scripted streaming event yielded by MockCompletionModel.
Variants§
Text(String)
Text chunk.
TextStart
Start a new text part with optional provider metadata.
TextAdditionalParams(Value)
Provider-specific metadata for the current text part.
ToolCall
Complete tool call event.
ToolCallNameDelta
A tool call’s name, as a wire streams it.
ToolCallArgumentsDelta
A fragment of a tool call’s arguments.
ToolCallEnd
The end of a tool call streamed as fragments: the call closes with what they carried, as a wire’s step-stop does.
Reasoning
Complete reasoning event.
ReasoningDelta
Reasoning delta event.
MessageId(String)
Provider-assigned message ID.
Unknown(Value)
Provider-native output item that Rig does not model.
RequestId(String)
The transport request id of this turn. The mock transport reports it, as a real transport reports a response header; the decoder never sees it. Its position in the turn does not matter; when a turn scripts more than one, the first wins.
FinalResponse(Finish)
The provider’s end of the reply.
Error(MockError)
A failure, which ends the reply.
Implementations§
Source§impl MockStreamEvent
impl MockStreamEvent
Sourcepub fn text(text: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn text(text: impl Into<String>) -> MockStreamEvent
test-utils only.Create a text chunk.
Sourcepub fn text_start(
id: impl Into<String>,
additional_params: Option<Value>,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn text_start( id: impl Into<String>, additional_params: Option<Value>, ) -> MockStreamEvent
test-utils only.Start a new text content block identified by id.
Sourcepub fn text_additional_params(additional_params: Value) -> MockStreamEvent
Available on crate features test-utils only.
pub fn text_additional_params(additional_params: Value) -> MockStreamEvent
test-utils only.Add provider-specific metadata to the current text content block.
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> MockStreamEvent
test-utils only.Create a complete tool call event.
Sourcepub fn with_call_id(self, call_id: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn with_call_id(self, call_id: impl Into<String>) -> MockStreamEvent
test-utils only.Attach a provider-specific call ID to a complete tool call event.
Sourcepub fn tool_call_name_delta(
id: impl Into<String>,
name: impl Into<String>,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn tool_call_name_delta( id: impl Into<String>, name: impl Into<String>, ) -> MockStreamEvent
test-utils only.Create a tool call name delta.
Sourcepub fn tool_call_arguments_delta(
id: impl Into<String>,
arguments: impl Into<String>,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn tool_call_arguments_delta( id: impl Into<String>, arguments: impl Into<String>, ) -> MockStreamEvent
test-utils only.Create a tool call arguments delta.
Sourcepub fn tool_call_end(id: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn tool_call_end(id: impl Into<String>) -> MockStreamEvent
test-utils only.Create the end of a tool call streamed as deltas.
Sourcepub fn reasoning(reasoning: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn reasoning(reasoning: impl Into<String>) -> MockStreamEvent
test-utils only.Create a complete reasoning event with the default mock id
("reasoning-0"). Use Self::with_reasoning_id for tests that
need distinct reasoning items.
Sourcepub fn with_reasoning_id(
self,
reasoning_id: impl Into<String>,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn with_reasoning_id( self, reasoning_id: impl Into<String>, ) -> MockStreamEvent
test-utils only.Attach a provider-specific reasoning ID to a complete reasoning event.
Sourcepub fn reasoning_delta(reasoning: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn reasoning_delta(reasoning: impl Into<String>) -> MockStreamEvent
test-utils only.Create a reasoning delta event with the default mock id
("reasoning-0"). Use Self::reasoning_delta_with_id for tests
that need distinct reasoning items.
Sourcepub fn reasoning_delta_with_id(
id: impl Into<String>,
reasoning: impl Into<String>,
) -> MockStreamEvent
Available on crate features test-utils only.
pub fn reasoning_delta_with_id( id: impl Into<String>, reasoning: impl Into<String>, ) -> MockStreamEvent
test-utils only.Create a reasoning delta event with an explicit reasoning item id.
Sourcepub fn message_id(id: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn message_id(id: impl Into<String>) -> MockStreamEvent
test-utils only.Create a provider-assigned message ID event.
Sourcepub fn unknown(value: Value) -> MockStreamEvent
Available on crate features test-utils only.
pub fn unknown(value: Value) -> MockStreamEvent
test-utils only.Create an unmodeled provider output item.
Sourcepub fn final_response(usage: Usage) -> MockStreamEvent
Available on crate features test-utils only.
pub fn final_response(usage: Usage) -> MockStreamEvent
test-utils only.Create the provider’s end of the reply, with usage.
Sourcepub fn final_response_with_default_usage() -> MockStreamEvent
Available on crate features test-utils only.
pub fn final_response_with_default_usage() -> MockStreamEvent
test-utils only.Create a final response event whose usage reports no counter.
Sourcepub fn final_response_with_total_tokens(total_tokens: u64) -> MockStreamEvent
Available on crate features test-utils only.
pub fn final_response_with_total_tokens(total_tokens: u64) -> MockStreamEvent
test-utils only.Create a final response event whose usage has only total_tokens set.
Sourcepub fn error(message: impl Into<String>) -> MockStreamEvent
Available on crate features test-utils only.
pub fn error(message: impl Into<String>) -> MockStreamEvent
test-utils only.Create a stream error event.
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 more