pub trait PgVectorStore: Send + Sync {
// Required methods
fn create_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
dimension: usize,
metric: Option<VectorMetric>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<VectorRecord>, VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<u64, VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn count<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, VectorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Vector Store core trait
Provides CRUD and similarity search capabilities for vector collections. All methods are async, suitable for real database I/O.
Required Methods§
Sourcefn create_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
dimension: usize,
metric: Option<VectorMetric>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
dimension: usize,
metric: Option<VectorMetric>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create collection
Sourcefn delete_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete collection
Sourcefn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Insert vector record (upsert semantics: same id overwrites)
Sourcefn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 [f32],
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Similarity search
M-16 fix: top_k must be in [1, MAX_TOP_K] range.
Implementations should call validate_top_k(top_k)? before executing search.
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<VectorRecord>, VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<VectorRecord>, VectorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get single record
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl PgVectorStore for InMemoryVectorStore
impl PgVectorStore for MemoryBatchOps
委托实现 PgVectorStore,将所有调用转发给内部 store