pub struct MockEmbeddingEngine { /* private fields */ }Expand description
A mock embedding engine.
Useful for testing pipeline stages that depend on an EmbeddingEngine
without requiring a real model or network connection. By default it returns
zero vectors (MockVectorMode::Zero); in MockVectorMode::Deterministic
it derives content-stable vectors from sha256(text).
Implementations§
Source§impl MockEmbeddingEngine
impl MockEmbeddingEngine
Sourcepub fn new(dimensions: usize) -> Self
pub fn new(dimensions: usize) -> Self
Create a mock engine with the given output dimensionality and a default batch size of 100.
Defaults to MockVectorMode::Zero.
Sourcepub fn with_batch_size(dimensions: usize, batch_size: usize) -> Self
pub fn with_batch_size(dimensions: usize, batch_size: usize) -> Self
Create a mock engine with explicit dimensionality and batch size.
Defaults to MockVectorMode::Zero.
Sourcepub fn deterministic(dimensions: usize) -> Self
pub fn deterministic(dimensions: usize) -> Self
Create a mock engine that produces deterministic, content-stable vectors
derived from sha256(text) (see MockVectorMode::Deterministic).
Sourcepub fn with_mode(self, mode: MockVectorMode) -> Self
pub fn with_mode(self, mode: MockVectorMode) -> Self
Override the vector-generation mode, consuming and returning self.
Sourcepub fn set_failure_after(&self, n: usize)
pub fn set_failure_after(&self, n: usize)
Configure the engine to fail after n successful embed calls.
With n = 0, the very first call fails. With n = 3, the first three
calls succeed and the fourth and beyond fail.
Sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
Number of embed invocations observed so far (one per batched call).
Sourcepub fn embedded_text_count(&self) -> usize
pub fn embedded_text_count(&self) -> usize
Total number of texts embedded across all embed invocations.
Trait Implementations§
Source§impl EmbeddingEngine for MockEmbeddingEngine
impl EmbeddingEngine for MockEmbeddingEngine
Source§fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = EmbeddingResult<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = EmbeddingResult<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn dimension(&self) -> usize
fn dimension(&self) -> usize
Source§fn batch_size(&self) -> usize
fn batch_size(&self) -> usize
Source§fn max_sequence_length(&self) -> usize
fn max_sequence_length(&self) -> usize
Auto Trait Implementations§
impl Freeze for MockEmbeddingEngine
impl RefUnwindSafe for MockEmbeddingEngine
impl Send for MockEmbeddingEngine
impl Sync for MockEmbeddingEngine
impl Unpin for MockEmbeddingEngine
impl UnsafeUnpin for MockEmbeddingEngine
impl UnwindSafe for MockEmbeddingEngine
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> 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