pub struct Mock { /* private fields */ }Expand description
Deterministic test backend.
Implementations§
Source§impl Mock
impl Mock
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a Mock that reports ready immediately and emits a single canned
token followed by Done.
Sourcepub fn with_config(config: MockConfig) -> Self
pub fn with_config(config: MockConfig) -> Self
Build a Mock with custom failure-mode configuration.
Trait Implementations§
Source§impl Backend for Mock
impl Backend for Mock
Source§fn capabilities(&self) -> BackendCapabilities
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,
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,
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
fn name(&self) -> &str
"mock", "llamacpp",
"anthropic". Echoed in Response::Done::backend for diagnostic
purposes (ADR 0007).Source§fn ready(&self) -> bool
fn ready(&self) -> bool
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,
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,
TokenEvent values. Read more