pub trait AsyncRetriever: Send + Sync {
type Query: Send + Sync;
type Result: Send + Sync;
type Error: Error + Send + Sync + 'static;
// Required methods
fn search<'life0, 'async_trait>(
&'life0 self,
query: Self::Query,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn search_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
query: Self::Query,
context: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'async_trait>(
&'life0 mut self,
content: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn search_batch<'life0, 'async_trait>(
&'life0 self,
queries: Vec<Self::Query>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Self::Result>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn update_batch<'life0, 'async_trait>(
&'life0 mut self,
content_batches: Vec<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn refresh_index<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn get_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<RetrievalStats>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Async text retrieval abstraction for non-blocking content retrieval
§Async Version
This trait provides async operations for content retrieval with better scalability and concurrency.
Required Associated Types§
Required Methods§
Sourcefn search<'life0, 'async_trait>(
&'life0 self,
query: Self::Query,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search<'life0, 'async_trait>(
&'life0 self,
query: Self::Query,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform a search query
Sourcefn search_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
query: Self::Query,
context: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
query: Self::Query,
context: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Perform a search with additional context
Provided Methods§
Sourcefn search_batch<'life0, 'async_trait>(
&'life0 self,
queries: Vec<Self::Query>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Self::Result>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search_batch<'life0, 'async_trait>(
&'life0 self,
queries: Vec<Self::Query>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Self::Result>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform multiple search queries concurrently
Sourcefn update_batch<'life0, 'async_trait>(
&'life0 mut self,
content_batches: Vec<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_batch<'life0, 'async_trait>(
&'life0 mut self,
content_batches: Vec<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update the retriever with new content in batches
Sourcefn refresh_index<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn refresh_index<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Refresh/rebuild the retrieval index