Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder:
    Send
    + Sync
    + 'static {
    // Required methods
    fn embed<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        inputs: &'life1 [&'life2 str],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn dim(&self) -> usize;
    fn handle(&self) -> &str;
}
Expand description

Producer of fixed-dimension float vectors for input text. Batched.

Adapters MUST:

  • Return exactly inputs.len() vectors, in the same order.
  • Each vector MUST be exactly dim() long.
  • Treat empty inputs as Ok(Vec::new()) (no provider call).

Required Methods§

Source

fn embed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, inputs: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Embed a batch of strings. Empty input → empty output, no provider call.

Source

fn dim(&self) -> usize

Output dimensionality. Constant per adapter instance.

Source

fn handle(&self) -> &str

Human-readable identifier, e.g. "gemini:text-embedding-004". Used in logs and to tag stored vectors so the schema can detect a dim change after a model swap.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§