pub trait EmbeddingBackend:
Send
+ Sync
+ Debug {
// Required methods
fn backend_name(&self) -> &str;
fn vector_dimension(&self) -> usize;
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Unified embedding backend for RAG and skill matching.
Implementations may be local (FastEmbed, Candle) or hosted (OpenAI, Voyage, Cohere). Callers operate against the trait and do not depend on a specific provider.
Required Methods§
Sourcefn backend_name(&self) -> &str
fn backend_name(&self) -> &str
Return the provider name for logging and diagnostics.
Sourcefn vector_dimension(&self) -> usize
fn vector_dimension(&self) -> usize
Return the expected output vector dimension.
Sourcefn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + 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<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Embed a batch of texts. The returned outer vector has the same length as
texts (unless texts is empty, in which case an empty vector is
returned). Each inner vector has vector_dimension() elements.
Implementations§
Source§impl dyn EmbeddingBackend
impl dyn EmbeddingBackend
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".