Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder {
    // Required methods
    fn model(&self, task: TaskKind) -> Option<(ModelId, ModelVersion)>;
    fn platform(&self) -> &str;
    fn embed(
        &self,
        asset_id: &str,
        task: TaskKind,
    ) -> Result<Vec<f32>, EmbedError>;
}
Expand description

The embedder seam the regeneration loop drives: “produce the canonical embedding for an asset under a task”. Abstracting it keeps the orchestration testable with a deterministic double and independent of any real model runtime.

Required Methods§

Source

fn model(&self, task: TaskKind) -> Option<(ModelId, ModelVersion)>

The (model_id, model_version) this embedder produces for task, or None if it does not serve that task (e.g. a non-embedding task). The loop refuses an embedder whose declared pair is not the registry canonical — its outputs would otherwise be stored under a tuple they did not produce.

Source

fn platform(&self) -> &str

The platform partition discriminator for this embedder’s outputs (incomparable across platforms; see the E2EE fallback in ai.md).

Source

fn embed(&self, asset_id: &str, task: TaskKind) -> Result<Vec<f32>, EmbedError>

Produce the embedding vector for asset_id under task. Its length must equal the task’s registry-declared dimension (the vector index re-checks this on insert).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§