1use async_trait::async_trait;
2use semtree_embed::Embedding;
3
4use crate::StoreError;
5
6#[derive(Debug, Clone)]
7pub struct Hit {
8 pub id: String,
9 pub score: f32,
10}
11
12#[async_trait]
13pub trait VectorStore: Send + Sync {
14 async fn insert(&self, id: &str, embedding: &Embedding) -> Result<(), StoreError>;
15 async fn search(&self, query: &Embedding, top_k: usize) -> Result<Vec<Hit>, StoreError>;
16 async fn delete(&self, id: &str) -> Result<(), StoreError>;
17 fn save(&self, path: &std::path::Path) -> Result<(), StoreError>;
18 fn load(&mut self, path: &std::path::Path) -> Result<(), StoreError>;
19 fn len(&self) -> usize;
20 fn is_empty(&self) -> bool {
21 self.len() == 0
22 }
23}