Skip to main content

ScriptedReply

Enum ScriptedReply 

Source
#[non_exhaustive]
pub enum ScriptedReply { Json(Value), Text(String), ToolCall { id: CallId, name: String, arguments: Value, }, MalformedJson(String), Refusal(String), Timeout, RateLimited { retry_after: Option<Duration>, }, Fail(ProviderError), Stream(Vec<StreamEvent>), Chunks(Vec<String>), FromSchema(fn(&Value) -> Value), }
Expand description

What one scripted call answers with.

The variants cover the answers a turn has to survive: the plan you meant, the plan you did not mean, a body that is not JSON at all, a refusal, and the three transport failures whose handling differs (timeout, rate limit, anything else).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Json(Value)

An arbitrary JSON document, for the shapes no typed value can express — an act with a field the schema forbids, a plan missing a required field.

§

Text(String)

Prose.

§

ToolCall

A single tool call, the shape a native function-schema transport produces.

Fields

§id: CallId

Call id echoed back to the runtime.

§name: String

Tool name.

§arguments: Value

Arguments, still untrusted.

§

MalformedJson(String)

A body that is not JSON. Sent verbatim, so the test decides how broken it is.

§

Refusal(String)

The model declined. A semantic outcome (FinishReason::Refusal), not a transport failure — the difference a runtime must not lose.

§

Timeout

The call did not answer in time.

§

RateLimited

The provider refused the call and asked the caller to wait.

Fields

§retry_after: Option<Duration>

The Retry-After hint, when the provider gave one.

§

Fail(ProviderError)

Any other normalized failure.

§

Stream(Vec<StreamEvent>)

Exactly these stream events, in this order.

§

Chunks(Vec<String>)

This text, delivered in these chunks. Equivalent to a Self::Stream of one text delta per chunk followed by a stop, and shorter to write.

§

FromSchema(fn(&Value) -> Value)

A document built from the request’s output schema, for a task whose schema depends on its input.

Implementations§

Source§

impl ScriptedReply

Source

pub fn text(text: impl Into<String>) -> Self

Prose.

Source

pub fn refusal(text: impl Into<String>) -> Self

A refusal.

Source

pub fn written(text: impl Into<String>) -> Self

What the acknowledge and answer tasks write: a document holding text.

Source

pub fn answer(text: impl Into<String>) -> Self

An answer the answer task writes.

Source

pub fn cannot_answer(reason: impl Into<String>) -> Self

The answer task saying the facts do not answer the question.

Source

pub fn review_passes() -> Self

A review that passes the reply: each check it was asked answered in its favour.

Source

pub fn review_fails() -> Self

A review that finds the reply claims what its material does not hold.

Source

pub fn rate_limited_after(seconds: u64) -> Self

A rate limit with a Retry-After hint in seconds.

Source

pub fn chunks<I, S>(chunks: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

A text answer split into chunks.

Source

pub const fn label(&self) -> &'static str

Stable snake-case label of the variant, safe in a failure message: it never carries the scripted value.

Trait Implementations§

Source§

impl Clone for ScriptedReply

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScriptedReply

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more