pub trait VectorStore:
Send
+ Sync
+ 'static {
// Required methods
fn insert_vectors<'life0, 'life1, 'async_trait, T>(
&'life0 self,
collection: &'life1 str,
records: Vec<T>,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where T: Serialize + Send + Sync + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search_vectors<'life0, 'life1, 'async_trait, T>(
&'life0 self,
collection: &'life1 str,
vector: Vec<f32>,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, String>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + Sync + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_vectors<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
collection: &'life1 str,
filter_field: &'life2 str,
filter_value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided method
fn setup_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
_collection: &'life1 str,
_dimension: u32,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Required Methods§
fn insert_vectors<'life0, 'life1, 'async_trait, T>( &'life0 self, collection: &'life1 str, records: Vec<T>, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
fn search_vectors<'life0, 'life1, 'async_trait, T>(
&'life0 self,
collection: &'life1 str,
vector: Vec<f32>,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, String>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + Sync + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_vectors<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
collection: &'life1 str,
filter_field: &'life2 str,
filter_value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Provided Methods§
Sourcefn setup_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
_collection: &'life1 str,
_dimension: u32,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn setup_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
_collection: &'life1 str,
_dimension: u32,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Ensures a collection is ready for vector operations.
This method is typically called during the application boot sequence or when a service starts up. It should be idempotent.
Depending on the underlying database, this method might:
- Define a schema or table if it doesn’t exist.
- Create necessary vector search indexes (e.g., M-Tree, HNSW).
- Do absolutely nothing if the database manages indexing transparently (e.g., Firestore).
By default, this does nothing and returns Ok(()). Storage providers that require
explicit schema or index definition must override this implementation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".