pub trait Embedder: Send + Sync {
// Required methods
fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedderError>;
fn dimension(&self) -> usize;
// Provided method
fn embed_batch(
&self,
texts: &[&str],
) -> Result<Vec<Vec<f32>>, EmbedderError> { ... }
}Expand description
Trait for text embedding backends.
Implementations convert text strings into dense vector representations suitable for semantic similarity search.
Required Methods§
Provided Methods§
Sourcefn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedderError>
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedderError>
Embed a batch of text strings into vectors.
Default implementation calls embed for each text sequentially.
Backends should override this for batch-optimized inference.
Trait Implementations§
Source§impl Embedder for Box<dyn Embedder>
Blanket implementation for boxed trait objects.
impl Embedder for Box<dyn Embedder>
Blanket implementation for boxed trait objects.