pub trait AsyncVectorIndex: Send + Sync {
// Required methods
fn add<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vectors: &'life1 [Vec<f32>],
ids: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search_filtered<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
allowlist: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn dim(&self) -> usize;
// Provided method
fn is_empty<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Async, object-safe vector index for remote/shared backends.
Implementations are remote vector services (Qdrant, Elasticsearch, …) whose
clients are async and shareable. Use dyn AsyncVectorIndex to abstract over
concrete backends.
IDs are always explicit — remote indexes do not auto-assign sequential IDs
the way an in-memory index can, so callers supply the u64 external IDs.
Required Methods§
Sourcefn add<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vectors: &'life1 [Vec<f32>],
ids: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn add<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vectors: &'life1 [Vec<f32>],
ids: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Upsert vectors keyed by their explicit external IDs.
Re-upserting an existing ID replaces its vector. vectors.len() must
equal ids.len().
Sourcefn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [u64],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove vectors by their external IDs.
IDs that do not exist are silently ignored. An empty slice is a no-op.
Sourcefn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Search for the k nearest neighbors of query.
Sourcefn search_filtered<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
allowlist: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_filtered<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
k: usize,
allowlist: &'life2 [u64],
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Search restricted to an allowlist of candidate IDs.
An empty allowlist yields no candidates, so an empty Vec is
returned (it does not fall back to an unfiltered search).
Mirrors VectorIndex::search_filtered:
narrow candidates (e.g. by metadata or BM25), then dense-rerank.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".