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:
- Providers. A
SearchProviderper findable kind answers bounded, paged queries (SearchQuery: text,Facetfilters, scope). A slow source returnsSearchPage::pendingand finishes throughSearchProvider::poll_page. - Rows. A hit says what it is with a
SearchRow(a message, a video, a file hit); the generic row is the fallback. - Opening search.
search_button/open_search_bindingopen the one platform palette narrowed to the app or one of its parts (SearchRequest,ScopeDecl);/and Ctrl+K do the same. - In-content narrowing is a
SearchFieldbound to aFilterablelist, and find in a document is theFindBarover aFindableview. Neither searches the app.
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§
- Body
Piece - 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:valuetokens for a declaredkeybecome the same structured filter. - Facet
Filter - One applied facet filter:
keyequalsvalue. - Facet
Value - One value a
Facetcan take:rustwith the label “Rust”. - Field
Weight - The share of
MAX_FIELD_RANKa match in one field is worth, in percent. - FnProvider
- A
SearchProviderbuilt from a closure plus its kind label — the convenient way to register a source without declaring a struct. Created viaSearchRegistry::register_fn. - List
Index - 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.
- Open
Resource Search - Automatic bounded search over the resources an app currently has open.
- Pending
Token - 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. - Scope
Decl - Search
Body - A body attached to a
SearchRecord. - Search
Catalog - A complete, incremental search catalogue keyed by canonical resource id.
- Search
Catalog Stats - Cheap diagnostics used by contract and performance tests.
- Search
Cursor - Opaque continuation for a bounded
SearchCatalogquery. - Search
Group - A ranked bucket of results that share a
SearchResult::kind. The results overlay renders one section per group, headed bykind. - Search
Opener - A latch a painted widget keeps to open search from its own input handling:
call
openfrom the handler and returntakefromActionControls::take_control_invocation. - Search
Page - One bounded page of a provider’s answer.
- Search
Query - One query as a provider receives it.
- Search
Record - One resource offered to a
SearchCatalog: its canonical hit, the short weighted fields it is found and ranked by, and optionally a longSearchBodyit is found by without the catalogue copying the prose. - Search
Registry - 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.
- Search
Request - A request to open the platform search from inside an app.
- Search
Result - One typed hit produced by a
SearchProvider.
Enums§
- Match
Tier - How strongly a query matched one field; later variants are stronger.
- Page
Poll - The answer to
SearchProvider::poll_page. - Search
Catalog Error - Search
Request Scope - What a search opened from an app narrows to.
- Search
Row - 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::searchentry point. Interactive callers usesearch_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§
- Catalog
Search Provider - A
SearchProvideranswered entirely from one retainedSearchCatalog. - Search
Body Source - Prose a catalogue record can be found by, owned by the app.
- Search
Provider - 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) toout. - fold_
search_ text - Fold complete text.
- locate
- The byte range in raw
textof the best occurrence ofqueryunder folding: the first one starting a word, else the first.Nonewhen 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_buttonis the launcher built on it). - open_
search_ invocation - The invocation a painted widget queues (through
ActionControls) to open the platform search withrequest;SearchOpenerkeeps 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
anchorisscopeor 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.