1pub mod usearch;
2
3use crate::error::Result;
4use uuid::Uuid;
5
6pub trait VectorIndex: Send + Sync {
7 fn add(&self, id: Uuid, vector: &[f32]) -> Result<()>;
8 fn remove(&self, id: Uuid) -> Result<()>;
9 fn search(&self, query: &[f32], limit: usize) -> Result<Vec<(Uuid, f32)>>;
10 fn filtered_search(
11 &self,
12 query: &[f32],
13 limit: usize,
14 filter: &dyn Fn(Uuid) -> bool,
15 ) -> Result<Vec<(Uuid, f32)>>;
16 fn save(&self, path: &std::path::Path) -> Result<()>;
17 fn load(&self, path: &std::path::Path) -> Result<()>;
18 fn len(&self) -> usize;
19 fn is_empty(&self) -> bool {
20 self.len() == 0
21 }
22}