Skip to main content

CatalogSearchProvider

Trait CatalogSearchProvider 

pub trait CatalogSearchProvider {
    const RESULT_LIMIT: usize = DEFAULT_SEARCH_RESULT_LIMIT;

    // Required methods
    fn provider_name(&self) -> &str;
    fn catalog(&self) -> Option<SearchCatalog>;

    // Provided methods
    fn limited_work_budget(&self, _limit: usize) -> usize { ... }
    fn catalog_query<'q>(&self, query: &'q str) -> Cow<'q, str> { ... }
    fn resolve_action_address(
        &self,
        _address: &ActionAddress,
    ) -> Option<Resource> { ... }
    fn facets(&self) -> Vec<Facet> { ... }
    fn search_scopes(&self) -> Vec<ScopeDecl> { ... }
    fn admits(&self, _hit: &SearchResult, _query: &SearchQuery) -> bool { ... }
}
Expand description

A SearchProvider answered entirely from one retained SearchCatalog.

Implementing this instead of SearchProvider gets the whole budgeted query surface from one blanket implementation: the action-directory generation and cursor checks read the catalogue’s generation, search and search_limited stop at the caller’s result limit, and search_page continues through SearchCatalog::query_page under both hard budgets. Nothing here scans or materialises past a caller’s budget, which is the invariant every app provider owes the shell’s search service.

Provided Associated Constants§

const RESULT_LIMIT: usize = DEFAULT_SEARCH_RESULT_LIMIT

The largest page search and search_limited return. Providers whose palette section shows fewer rows lower it.

Required Methods§

fn provider_name(&self) -> &str

Group label and diagnostic name, as SearchProvider::name.

fn catalog(&self) -> Option<SearchCatalog>

The catalogue answering queries, or None while none is published (a provider with no catalogue reports no generation and empty pages).

Cloning a SearchCatalog is O(1), so providers that keep theirs behind a lock return a clone taken under it.

Provided Methods§

fn limited_work_budget(&self, _limit: usize) -> usize

Candidate-inspection budget for a one-shot search_limited(limit) call. The default inspects up to DEFAULT_SEARCH_CANDIDATE_LIMIT candidates to fill limit results; a provider may instead spend no more inspections than results it asked for. query_page caps either at the shared ceiling.

fn catalog_query<'q>(&self, query: &'q str) -> Cow<'q, str>

Rewrite the caller’s query into the form the catalogue was indexed with, for providers that fold their own text before indexing.

fn resolve_action_address(&self, _address: &ActionAddress) -> Option<Resource>

fn facets(&self) -> Vec<Facet>

fn search_scopes(&self) -> Vec<ScopeDecl>

As SearchProvider::search_scopes: the parts of the app this catalogue’s hits can be narrowed to.

fn admits(&self, _hit: &SearchResult, _query: &SearchQuery) -> bool

Whether hit passes query’s facet filters. The catalogue matches text only; a provider with facets checks the hit’s values here (query.admits("language", &[..])). The default admits every hit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§