Skip to main content

SearchProvider

Trait SearchProvider 

Source
pub trait SearchProvider: Send + Sync {
    // Required method
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        n: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Web/code search backend abstraction.

Why: Swap Brave for Tavily / DuckDuckGo / a test stub by changing the registered impl — no callers change. What: search(query, n) returns up to n results. Test: A stub SearchProvider returns a fixed vector in mock tests.

Required Methods§

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, n: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run a search for query and return up to n results.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§