pub trait Embedder: Send + Sync {
// Required method
fn embed(&self, text: &str) -> Result<Vec<f32>>;
// Provided method
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> { ... }
}Expand description
Sync embedding interface.
ONNX inference is CPU-bound and cannot yield to the async runtime.
Callers must wrap calls in tokio::task::spawn_blocking.
Required Methods§
Provided Methods§
Sourcefn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
Embed a batch of texts. Default implementation calls Self::embed
once per text; concrete types may override for batched inference.
§Errors
Returns an error if any embedding fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".