Skip to main content

Scripted

Struct Scripted 

Source
pub struct Scripted { /* private fields */ }
Expand description

The honest “second impl” (D9): a scripted provider driving the real engine in tests. Each stream() call pops the next script.

Implementations§

Source§

impl ScriptedProvider

Source

pub fn new( scripts: Vec<Vec<Result<StreamEvent, ProviderError>>>, ) -> ScriptedProvider

Source

pub fn requests(&self) -> Vec<SamplingRequest>

Every captured request. Cheap since a request’s history/tools are shared (Arc) — the clone copies pointers, not items.

Source

pub fn last_request(&self) -> Option<SamplingRequest>

The most recent request, if any.

Source

pub fn request_count(&self) -> usize

Source

pub fn push_script(&self, script: Vec<Result<StreamEvent, ProviderError>>)

Append a script after construction (tests that need the harness’s paths before the scripts can be written).

Source

pub fn text_reply(text: &str) -> Vec<Result<StreamEvent, ProviderError>>

Convenience: a one-sample script that answers with plain text.

Source

pub fn tool_call( id: &str, name: &str, input: Value, ) -> Vec<Result<StreamEvent, ProviderError>>

Convenience: a sample that calls one tool.

Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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