pub struct MockEmbeddingProvider { /* private fields */ }Expand description
Mock embedding provider for testing and development
Provides deterministic, fast embedding generation for testing purposes. The mock provider generates consistent embeddings based on input text, making it suitable for unit tests and development workflows.
§Features
- Deterministic: Same input always produces the same embedding
- Fast: No network calls or heavy computation
- Configurable: Adjustable dimensions and behavior
- Testing-Friendly: Predictable behavior for assertions
§Example
use rrag::prelude::*;
use std::sync::Arc;
let provider = Arc::new(MockEmbeddingProvider::new());
let service = EmbeddingService::new(provider);
let document = Document::new("Test content");
let embedding = service.embed_document(&document).await?;
// Mock provider always returns 384 dimensions
assert_eq!(embedding.dimensions, 384);
assert_eq!(embedding.model, "mock-model");Implementations§
Trait Implementations§
Source§impl EmbeddingProvider for MockEmbeddingProvider
impl EmbeddingProvider for MockEmbeddingProvider
Source§fn supported_models(&self) -> Vec<&str>
fn supported_models(&self) -> Vec<&str>
Supported models for this provider
Source§fn max_batch_size(&self) -> usize
fn max_batch_size(&self) -> usize
Maximum batch size supported
Source§fn embedding_dimensions(&self) -> usize
fn embedding_dimensions(&self) -> usize
Embedding dimensions for the current model
Source§fn embed_text<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = RragResult<Embedding>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_text<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = RragResult<Embedding>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generate embedding for a single text
Source§fn embed_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<EmbeddingRequest>,
) -> Pin<Box<dyn Future<Output = RragResult<EmbeddingBatch>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn embed_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<EmbeddingRequest>,
) -> Pin<Box<dyn Future<Output = RragResult<EmbeddingBatch>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate embeddings for multiple texts (more efficient)
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RragResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RragResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check for the provider
Auto Trait Implementations§
impl Freeze for MockEmbeddingProvider
impl RefUnwindSafe for MockEmbeddingProvider
impl Send for MockEmbeddingProvider
impl Sync for MockEmbeddingProvider
impl Unpin for MockEmbeddingProvider
impl UnwindSafe for MockEmbeddingProvider
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
Mutably borrows from an owned value. Read more