pub trait EmbeddingBackend:
Send
+ Sync
+ Debug {
// Required methods
fn id(&self) -> &str;
fn dimension(&self) -> u16;
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Turns text into dense vectors.
Implementations MUST be deterministic for the same input when
backend.id() stays the same — this is a load-bearing property
of the kyma replay cache.
Required Methods§
Sourcefn id(&self) -> &str
fn id(&self) -> &str
Stable identifier, e.g. "fastembed/bge-small-en-v1.5" or
"openai/text-embedding-3-small". Mixing IDs across writes
is a correctness bug (distance-space mismatch) — the engine
tags every vector column with its model_id.
Sourcefn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Compute embeddings for a batch. Order of outputs matches inputs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".