pub trait Embedder: Send + Sync {
// Required methods
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn dimension(&self) -> usize;
}Expand description
Abstraction over embedding backends.
Why: Decouple consumers from any one model so we can swap in remote APIs,
quantised models, or deterministic mocks without changing call sites.
What: a single primitive — embed_batch — plus a dimension accessor.
Single-text callers should use the embed_one convenience helper.
Test: covered by FastEmbedder and MockEmbedder tests below.
Required Methods§
Sourcefn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Embed a batch of texts. Returns one Vec<f32> per input, each of
length self.dimension(). An empty input batch returns an empty Vec.