pub trait EmbeddingModel:
Send
+ Sync
+ 'static {
// Required methods
fn embed(
&self,
text: &str,
) -> impl Future<Output = Result<Vec<f32>, EmbeddingError>> + Send;
fn dimensions(&self) -> usize;
}Expand description
Produces a fixed-dimension float vector from a text input.
Implementations must be deterministic: embedding the same input twice
returns identical vectors. The returned vector’s length must equal
Self::dimensions.
Required Methods§
Sourcefn embed(
&self,
text: &str,
) -> impl Future<Output = Result<Vec<f32>, EmbeddingError>> + Send
fn embed( &self, text: &str, ) -> impl Future<Output = Result<Vec<f32>, EmbeddingError>> + Send
Embeds text into a Self::dimensions-length vector.
§Errors
Returns EmbeddingError::Embed when inference fails. Init-time
failures surface from the implementation’s constructor.
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Returns the dimension of vectors produced by Self::embed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".