pub struct MockTurn { /* private fields */ }test-utils only.Expand description
A scripted non-streaming mock completion turn.
Implementations§
Source§impl MockTurn
impl MockTurn
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 tool-call response turn.
Sourcepub fn provider_response_error(
status: StatusCode,
body: impl Into<String>,
request_id: impl Into<String>,
) -> Self
pub fn provider_response_error( status: StatusCode, body: impl Into<String>, request_id: impl Into<String>, ) -> Self
Create a provider-response error turn carrying a transport request id (rig#2314): the scripted failure a test uses to assert error-identity attribution.
Sourcepub fn request_error(message: impl Into<String>) -> Self
pub fn request_error(message: impl Into<String>) -> Self
Create a request-error response turn.
Sourcepub fn from_content(content: AssistantContent) -> Self
pub fn from_content(content: AssistantContent) -> Self
Create a response turn from one assistant content item.
Sourcepub fn from_contents(
content: impl IntoIterator<Item = AssistantContent>,
) -> Self
pub fn from_contents( content: impl IntoIterator<Item = AssistantContent>, ) -> Self
Create a response turn from assistant content items.
Infallible now that content is a Vec: an empty turn is a shape a
provider can genuinely return, so it is a value to build, not an error.
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 tool-call response turn.
Sourcepub fn with_usage(self, usage: Usage) -> Self
pub fn with_usage(self, usage: Usage) -> Self
Override usage for this turn.
Sourcepub fn with_message_id(self, message_id: impl Into<String>) -> Self
pub fn with_message_id(self, message_id: impl Into<String>) -> Self
Set a provider-assigned assistant message ID for this turn.
Sourcepub fn with_response_id(self, response_id: impl Into<String>) -> Self
pub fn with_response_id(self, response_id: impl Into<String>) -> Self
Set a provider-assigned response-scoped ID for this turn.
Sourcepub fn with_provider_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_provider_request_id(self, request_id: impl Into<String>) -> Self
Set a provider transport request id for this turn.
Sourcepub fn with_finish_reason(self, finish_reason: FinishReason) -> Self
pub fn with_finish_reason(self, finish_reason: FinishReason) -> Self
Set the terminal finish reason for this turn.
Without this, a mocked blocking turn always reports None, which
leaves the whole blocking half of the truncation contract (rig#2322)
unexercisable — the streamed mock could script a reason and the
blocking one could not.
Sourcepub fn with_raw(self, raw: Value) -> Self
pub fn with_raw(self, raw: Value) -> Self
Script the provider’s own response for this turn — what a real seam
would serialize from its raw type. Attached to the response as-is, so
agent tests can prove the payload reaches every observer of the turn
without a live provider. A turn without a scripted payload reports
raw: Value::Null, so a non-null raw in a test means the scripted
value arrived, never that the mock invented one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockTurn
impl RefUnwindSafe for MockTurn
impl Send for MockTurn
impl Sync for MockTurn
impl Unpin for MockTurn
impl UnsafeUnpin for MockTurn
impl UnwindSafe for MockTurn
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> 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