Public declaration syntax from forge-rs/crates/forge-embed/src/vector_store.rs Original source SHA-256: 2857ad400d7305d797a88518d5cfba5c391b4c48d9923175963de90541055b8d Function bodies and constant values are omitted. This is not the complete implementation. Source line 56 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct VectorEntry { /// Unique identifier for this entry. pub id: String, /// The embedding vector. pub vector: Vec, /// Arbitrary metadata associated with this entry. pub metadata: serde_json::Value } Source line 86 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SearchResult { /// The matched vector entry. pub entry: VectorEntry, /// The similarity score (higher is more similar). pub score: f64 } Source line 131 #[async_trait] pub trait VectorStore: Send + Sync { /// Inserts or updates a vector entry in the store. /// /// If an entry with the same `id` already exists, it is replaced. /// /// # Arguments /// /// * `entry` - The vector entry to insert. /// /// # Errors /// /// Returns [`ForgeEmbedError::StoreError`] if the insertion fails. async fn insert(&mut self, entry: VectorEntry) -> EmbedResult<()>; /// Searches for the nearest vectors to the query. /// /// Returns up to `top_k` results sorted by descending similarity score. /// /// # Arguments /// /// * `query` - The query embedding vector. /// * `top_k` - Maximum number of results to return. /// /// # Returns /// /// A vector of [`SearchResult`] sorted by descending similarity score. /// /// # Errors /// /// Returns [`ForgeEmbedError::StoreError`] if the search fails. /// Returns [`ForgeEmbedError::EmptyInput`] if the query vector is empty. async fn search(&self, query: &[f64], top_k: usize) -> EmbedResult>; /// Deletes a vector entry by ID. /// /// # Arguments /// /// * `id` - The identifier of the entry to delete. /// /// # Returns /// /// `true` if the entry was found and deleted, `false` if it did not exist. /// /// # Errors /// /// Returns [`ForgeEmbedError::StoreError`] if the deletion fails. async fn delete(&mut self, id: &str) -> EmbedResult; } Source line 212 #[derive(Debug, Default)] pub struct InMemoryVectorStore { } Source line 227 pub fn new() -> Self; Source line 234 pub fn len(&self) -> usize; Source line 239 pub fn is_empty(&self) -> bool; Source line 244 pub fn contains(&self, id: &str) -> bool; Source line 249 pub fn get(&self, id: &str) -> Option<&VectorEntry>;