SearchProvider

Trait SearchProvider 

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

Trait for search providers.

Implement this trait to add support for different search engines.

§Example

struct MySearchProvider { /* ... */ }

#[async_trait]
impl SearchProvider for MySearchProvider {
    async fn search(&self, query: &str, max_results: usize) -> Result<SearchResponse> {
        // Implementation
    }

    fn provider_name(&self) -> &'static str {
        "my-provider"
    }
}

Required Methods§

Source

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

Execute a search query.

§Arguments
  • query - The search query string
  • max_results - Maximum number of results to return
§Errors

Returns an error if the search request fails.

Source

fn provider_name(&self) -> &'static str

Get the provider name for logging/debugging.

Implementors§