pub enum MockStreamEvent {
Show 13 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,
text: String,
},
ReasoningDelta {
id: String,
reasoning: 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 the provider item it is decoded from.
TextAdditionalParams(Value)
Fields merged into the current text part’s provider item.
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.
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_start(
id: impl Into<String>,
additional_params: Option<Value>,
) -> Self
pub fn text_start( id: impl Into<String>, additional_params: Option<Value>, ) -> Self
Start a new text content block identified by id.
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>,
name: impl Into<String>,
) -> Self
pub fn tool_call_name_delta( 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>,
arguments: impl Into<String>,
) -> Self
pub fn tool_call_arguments_delta( id: impl Into<String>, arguments: impl Into<String>, ) -> Self
Create a tool call arguments delta.
Sourcepub fn tool_call_end(id: impl Into<String>) -> Self
pub fn tool_call_end(id: impl Into<String>) -> Self
Create the end of a tool call streamed as deltas.
Sourcepub fn reasoning(reasoning: impl Into<String>) -> Self
pub fn reasoning(reasoning: impl Into<String>) -> Self
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>) -> 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(reasoning: impl Into<String>) -> Self
pub fn reasoning_delta(reasoning: impl Into<String>) -> Self
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>,
) -> Self
pub fn reasoning_delta_with_id( id: impl Into<String>, reasoning: impl Into<String>, ) -> Self
Create a reasoning delta event with an explicit reasoning item id.
Sourcepub fn final_response(usage: Usage) -> Self
pub fn final_response(usage: Usage) -> Self
Create the provider’s end of the reply, with usage.
Sourcepub fn final_response_with_default_usage() -> Self
pub fn final_response_with_default_usage() -> Self
Create a final response event whose usage reports no counter.
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§impl Debug for MockStreamEvent
impl Debug for MockStreamEvent
Source§impl<'de> Deserialize<'de> for MockStreamEvent
impl<'de> Deserialize<'de> for MockStreamEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MockStreamEvent
impl PartialEq for MockStreamEvent
Source§impl Serialize for MockStreamEvent
impl Serialize for MockStreamEvent
impl StructuralPartialEq for MockStreamEvent
Auto 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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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