pub trait VectorDB: Send + Sync {
// Required methods
fn create_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
dimension: usize,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn has_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn index_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
points: &'life3 [VectorPoint],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vector: &'life3 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn delete_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn collection_size<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<usize, VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
// Provided methods
fn delete_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
point_ids: &'life3 [Uuid],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait { ... }
fn list_collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn prune<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn batch_search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vectors: &'life3 [Vec<f32>],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<SearchResult>>, VectorDBError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Vector database trait
Required Methods§
Sourcefn create_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
dimension: usize,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn create_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
dimension: usize,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Sourcefn has_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn has_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Sourcefn index_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
points: &'life3 [VectorPoint],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn index_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
points: &'life3 [VectorPoint],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Index data points (batch upsert with embeddings already generated)
§Arguments
data_type- Type namefield_name- Field namepoints- Vector points with embeddings
§Example
let points = vec![
VectorPoint::new(chunk_id, embedding)
.with_metadata("type", json!("DocumentChunk"))
.with_metadata("field", json!("text")),
];
vector_db.index_points("DocumentChunk", "text", &points).await?;Sourcefn search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vector: &'life3 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vector: &'life3 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Sourcefn delete_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn delete_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Delete collection
Sourcefn collection_size<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<usize, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn collection_size<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<usize, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Get collection statistics
Provided Methods§
Sourcefn delete_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
point_ids: &'life3 [Uuid],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn delete_points<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
point_ids: &'life3 [Uuid],
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Delete points by IDs from an existing collection.
Sourcefn list_collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list_collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
List all existing vector collections as (data_type, field_name) pairs.
Default implementation returns an empty list. Backends should override to return the actual collections they hold.
Sourcefn prune<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn prune<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Remove all vector collections.
Default implementation lists all collections and deletes each one. Backends may override with a more efficient bulk operation.
Equivalent to Python’s vector_engine.prune().
Sourcefn batch_search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vectors: &'life3 [Vec<f32>],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<SearchResult>>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn batch_search_similar<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
data_type: &'life1 str,
field_name: &'life2 str,
query_vectors: &'life3 [Vec<f32>],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<SearchResult>>, VectorDBError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Perform multiple vector similarity searches in sequence.
Default implementation loops over [search_similar]. Backends may override
this with a native batch API for better performance.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".