Skip to main content

SearchProvider

Trait SearchProvider 

Source
pub trait SearchProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn is_available(&self) -> bool;
    fn weight(&self) -> f64;
    fn set_weight(&mut self, weight: f64);
    fn set_enabled(&mut self, enabled: bool);
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        options: &'life2 SearchOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, SearchError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn search_with_transport<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        options: &'life2 SearchOptions,
        transport: &'life3 dyn SearchTransport,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, SearchError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Trait that all search providers must implement

Required Methods§

Source

fn name(&self) -> &str

Get the provider name

Source

fn is_available(&self) -> bool

Check if the provider is available/enabled

Source

fn weight(&self) -> f64

Get the provider weight for reranking

Source

fn set_weight(&mut self, weight: f64)

Set the provider weight for reranking

Source

fn set_enabled(&mut self, enabled: bool)

Enable or disable the provider

Source

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

Perform a search with the provider’s default transport.

Provided Methods§

Source

fn search_with_transport<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, query: &'life1 str, options: &'life2 SearchOptions, transport: &'life3 dyn SearchTransport, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, SearchError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Perform a search with a caller-owned transport.

The default preserves compatibility for third-party providers; built-in providers override this method so every network request is routed through the supplied transport.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§