pub trait EmbeddingProvider: Send + Sync {
// Required methods
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn dimensions(&self) -> usize;
fn model_id(&self) -> &str;
// Provided methods
fn max_batch_size(&self) -> usize { ... }
fn embed_one<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Embedding, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Core embedding provider trait.
All implementations must be Send + Sync for use across async boundaries.
embed is async to support both local inference (via spawn_blocking)
and API-based providers (network IO).
Required Methods§
Sourcefn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>, EmbedError>> + 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 = Result<Vec<Embedding>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Generate embeddings for a batch of texts.
Returns one embedding per input text, in the same order.
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Vector dimensionality of this provider.
Provided Methods§
Sourcefn max_batch_size(&self) -> usize
fn max_batch_size(&self) -> usize
Maximum batch size supported.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".