Skip to main content

Module search

Module search 

Expand description

Search as a platform service.

Apps never draw a search field or a result list. An app declares what it can find and the platform presents it:

use tilo_ui::search::{SearchRegistry, SearchResult};

let mut registry = SearchRegistry::new();
registry.register_fn("Contacts", |q: &str| {
    ["Alice Ng", "Bob Reyes"]
        .into_iter()
        .filter(|name| name.to_lowercase().contains(&q.to_lowercase()))
        .map(|name| SearchResult::new("Contacts", name, name))
        .collect()
});

let groups = registry.query_grouped("al");
assert_eq!(groups[0].kind, "Contacts");
assert_eq!(groups[0].results[0].title, "Alice Ng");

Modules§

capability
How a widget contributes to the unified search: providers folded into the Ctrl+K palette and system search, and activating one of its hits.
fold_search_text
Text folding shared by indexing, queries and anything that compares a query with displayed text.
rank
Merging hits from different sources.
system
Native and browser system-search policy. Activation payloads remain host-owned.

Structs§

BodyPiece
One contiguous run of body text.
Facet
A dimension a provider can filter by: a snippet’s language, a store item’s category, a message’s sender. The palette shows its values as filter chips beside the kind chips, and typed key:value tokens for a declared key become the same structured filter.
FacetFilter
One applied facet filter: key equals value.
FacetValue
One value a Facet can take: rust with the label “Rust”.
FieldWeight
The share of MAX_FIELD_RANK a match in one field is worth, in percent.
FnProvider
A SearchProvider built from a closure plus its kind label — the convenient way to register a source without declaring a struct. Created via SearchRegistry::register_fn.
ListIndex
Ranks the rows of a list against a query, for surfaces that rebuild their rows on every query or change (commands, windows, actions).
Matching
What besides the whole query as a substring counts as a match.
OpenResourceSearch
Automatic bounded search over the resources an app currently has open.
PendingToken
A provider’s handle on one outstanding request to a slow source. Opaque to the palette, which only hands it back to SearchProvider::poll_page.
ScopeDecl
SearchBody
A body attached to a SearchRecord.
SearchCatalog
A complete, incremental search catalogue keyed by canonical resource id.
SearchCatalogStats
Cheap diagnostics used by contract and performance tests.
SearchCursor
Opaque continuation for a bounded SearchCatalog query.
SearchGroup
A ranked bucket of results that share a SearchResult::kind. The results overlay renders one section per group, headed by kind.
SearchOpener
A latch a painted widget keeps to open search from its own input handling: call open from the handler and return take from ActionControls::take_control_invocation.
SearchPage
One bounded page of a provider’s answer.
SearchQuery
One query as a provider receives it.
SearchRecord
One resource offered to a SearchCatalog: its canonical hit, the short weighted fields it is found and ranked by, and optionally a long SearchBody it is found by without the catalogue copying the prose.
SearchRegistry
The set of providers a search surface draws from. One registry can back a single app (its own providers) or, in the shell, every app’s providers at once for a global Ctrl+K.
SearchRequest
A request to open the platform search from inside an app.
SearchResult
One typed hit produced by a SearchProvider.

Enums§

MatchTier
How strongly a query matched one field; later variants are stronger.
PagePoll
The answer to SearchProvider::poll_page.
SearchCatalogError
SearchRequestScope
What a search opened from an app narrows to.
SearchRow
The shape of one search hit’s row.

Constants§

DEFAULT_SEARCH_CANDIDATE_LIMIT
Default maximum number of hits an indexed provider materialises for one interactive query page. The index holds the complete corpus; this is a query-time latency budget, not a data-loss limit.
DEFAULT_SEARCH_INDEX_LIMIT
Legacy snapshot-size constant.
DEFAULT_SEARCH_RESULT_LIMIT
Maximum number of rows a provider should return from the legacy, unbudgeted SearchProvider::search entry point. Interactive callers use search_limited; this ceiling keeps tests and secondary consumers from accidentally materialising an entire library.
MAX_FIELD_RANK
Top of the rank scale: an exact match in a full-weight field.
MAX_SEARCH_QUERY_SCALARS
Maximum Unicode scalar values accepted from one interactive query.

Traits§

CatalogSearchProvider
A SearchProvider answered entirely from one retained SearchCatalog.
SearchBodySource
Prose a catalogue record can be found by, owned by the app.
SearchProvider
A source of search results — implemented by an app for each searchable type it exposes (its contacts, its open files, its commands, …).

Functions§

fold_char
Append the folded form of scalar (zero or more scalars) to out.
fold_search_text
Fold complete text.
locate
The byte range in raw text of the best occurrence of query under folding: the first one starting a word, else the first. None when the query is empty or absent.
normalize_search_text
Fold text the way every index does: case, compatibility forms and alphabetic diacritics (see [tilo_search::fold]).
open_search_binding
Bind a control to open the platform search with request (search_button is the launcher built on it).
open_search_invocation
The invocation a painted widget queues (through ActionControls) to open the platform search with request; SearchOpener keeps one for it.
result_relevance
How the query meets one displayed hit, for merging sources: the tier in its title, else in its subtitle at subtitle weight.
scope_contains
Whether anchor is scope or lies beneath it in the anchor path.
search_button
The search launcher: an icon-only magnifier button that opens the platform search with request. This is the only search affordance an app puts in its chrome; it never draws a field.