Skip to main content

Mock

Struct Mock 

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

Deterministic test backend.

Implementations§

Source§

impl Mock

Source

pub fn new() -> Self

Build a Mock that reports ready immediately and emits a single canned token followed by Done.

Source

pub fn with_config(config: MockConfig) -> Self

Build a Mock with custom failure-mode configuration.

Source

pub fn set_ready(&self, ready: bool)

Toggle the backend’s reported readiness. Used by tests of the listener-gate invariant.

Trait Implementations§

Source§

impl Backend for Mock

Source§

fn capabilities(&self) -> BackendCapabilities

Mock advertises v2 + thinking + embed so daemon-side dispatch across all three sockets can be exercised end-to-end without a real engine. Multimodal / tool flags stay false — Mock doesn’t pretend to ingest images or parse tool calls.

Source§

fn generate_v2<'life0, 'async_trait>( &'life0 self, _req: ResolvedV2, ) -> Pin<Box<dyn Future<Output = Result<TokenStreamV2, GenerateError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

v2 generation. Same token tape + delays as generate but emits TokenEventV2::Text(...) and a v2 Done frame with StopReasonV2::EndTurn and UsageV2 field names. Mid-stream drop and pre-stream error knobs apply identically.

Source§

fn embed<'life0, 'async_trait>( &'life0 self, req: EmbedResolved, ) -> Pin<Box<dyn Future<Output = Result<EmbedResult, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deterministic mock embedding. Emits one fixed-length vector per input string; entries are derived from the input length so tests can assert correlation. dimensions defaults to 8 when the request doesn’t supply one; otherwise the request’s value is honoured (no model-specific MRL set to validate against). Pre-stream-error knob (MockError::Unavailable / InvalidRequest) is reused on the embed path to exercise daemon-side error mapping; NotReady mode short-circuits to EmbedError::NotReady to mirror the v1/v2 paths.

Source§

fn name(&self) -> &str

Stable identifier for the backend, e.g. "mock", "llamacpp", "anthropic". Echoed in Response::Done::backend for diagnostic purposes (ADR 0007).
Source§

fn ready(&self) -> bool

Whether the backend has finished its boot sequence and can serve requests. The daemon does not create its inference listener until every registered backend reports true (see THREAT_MODEL.md F-13).
Source§

fn generate<'life0, 'async_trait>( &'life0 self, _req: Resolved, ) -> Pin<Box<dyn Future<Output = Result<TokenStream, GenerateError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Begin a generation and return a stream of TokenEvent values. Read more
Source§

fn stop<'life0, 'async_trait>( &'life0 self, _timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), GenerateError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Best-effort graceful shutdown. The daemon calls this on stop; the adapter should release model memory, terminate worker threads, and any other long-lived resources within the deadline.
Source§

impl Default for Mock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Mock

§

impl RefUnwindSafe for Mock

§

impl Send for Mock

§

impl Sync for Mock

§

impl Unpin for Mock

§

impl UnsafeUnpin for Mock

§

impl UnwindSafe for Mock

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<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, 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.