Trait bindle::search::Search

source ·
pub trait Search {
    // Required methods
    fn query<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        term: &'life1 str,
        filter: &'life2 str,
        options: SearchOptions
    ) -> Pin<Box<dyn Future<Output = Result<Matches>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn index<'life0, 'life1, 'async_trait>(
        &'life0 self,
        document: &'life1 Invoice
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

This trait describes the minimal set of features a Bindle provider must implement to provide query support.

Implementors of this trait should handle any locking of the internal index in their implementation Please note that due to this being an async_trait, the types might look complicated. Look at the code directly to see the simpler function signatures for implementation

Required Methods§

source

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

A high-level function that can take raw search strings (queries and filters) and options.

This will parse the terms and filters according to its internal rules, and return a set of matches.

An error is returned if either there is something incorrect in the terms/filters, or if the search engine itself fails to process the query.

source

fn index<'life0, 'life1, 'async_trait>( &'life0 self, document: &'life1 Invoice ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Given an invoice, extract information from it that will be useful for searching.

This high-level feature does not provide any guarantees about how it will process the invoice. But it may implement Strict and/or Standard modes described in the protocol specification.

If the index function is given an invoice it has already indexed, it treats the call as an update. Otherwise, it adds a new entry to the index.

As a special note, if an invoice is yanked, the index function will mark it as such, following the protocol specification’s requirements for yanked invoices.

Implementors§