Module search
Expand description
Search as a platform service: apps never draw a search field or a result list, they declare what they 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; 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.
- index_
publication - An app’s search entries as the system’s persistent search index takes them.
- rank
- Merging hits from different sources.
- scope
- What one search reaches: the one scope vocabulary, from the narrowest to the widest.
- system
- Native and browser system-search policy. Activation payloads remain host-owned.
Structs§
- Alternate
- What a row does when it is activated with
modifierheld, in the words the selected row shows while that modifier is down (“Opens as a tab here”). - Anchor
- The resource a search is opened on, and the text that finds its row.
- AppScope
- One app’s own search: the app, and the part of it a control asked for.
- Body
Piece - One contiguous run of body text.
- Command
Row - The slots of a
SearchRow::Commandrow beyond its title, subtitle and icon. - 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. - Frecency
- What was chosen how often and when, by an id the caller picks (a package id, an action id). Time is passed in as seconds since the epoch, so the ranking is testable without a clock.
- 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. - RowFace
- One person in a row’s face stack (
CommandRow::faces). - Scope
Decl - Search
Body - A body attached to a
SearchRecord. - Search
Button search_buttonfor the whole app, made from its description.- Search
Button Props - The one search affordance an app puts in its chrome: an icon button that opens the platform search over the whole app. It never draws a field, and a window bar that searches for the window takes its place.
- 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
Offer - A system action an app prepares for the person (
SearchRequest::offer): the action’s id and the text arguments the app fills in. The host decides which of its actions an app may prepare, and asks the person for every other argument, the confirmation among them. - 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
Preview - The preview of one search hit.
- 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§
- Activation
Modifier - A modifier held while a row is activated, choosing an alternative
activation the row offers (
CommandRow::alternates). - Match
Tier - How strongly a query matched one field; later variants are stronger.
- Page
Poll - The answer to
SearchProvider::poll_page. - Scope
- How far one search reaches, from narrowest to widest: the one vocabulary every control that opens search asks in.
- Search
Catalog Error - Search
Row - The shape of one search hit’s row.
Constants§
- APP_
SEARCH_ BUTTON_ ID - The id of the button
search_buttonmakes for the whole app. A window bar that presents search for the window replaces it: a header that holds the window’s bar controls (crate::widget::WindowHeader) drops it. - 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.
- PREVIEW_
BODY_ LINES - How many lines the band wraps a
SearchPreview::bodyover. - PREVIEW_
LINES - How many
SearchPreview::linesthe band shows.
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§
- engine_
generation - How many times the engine arrived: never, as it was always there.
- engine_
ready - Whether no search waits for the engine: none does, it is linked in.
- fold_
char - Append the folded form of
scalar(zero or more scalars) toout. - fold_
search_ text - Fold complete text.
- initials
- The first letters of a title’s words, folded:
Word Processoriswp, so the two letters typed for it find it.Nonefor a title of one word, which has nothing to abbreviate. - is_
search_ address - Whether
addressnames the host search door. - locate
- The byte range in raw
text, a field ofweight, of the occurrence ofquerythe index matches there under folding: the first one starting a word, or inside a word where a field ofweightmatches inside words (a name or an identity, the query long enough to be a fragment). A query only beginning a name (MIN_ALIAS_SCALARS) shows in any other field only as a whole word.Nonewhere the index finds no match. - 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. - ranked_
rows - The rows of a short list that answer
query, best first, ranked byindexthe way every list search ranks; rows that rank alike keep the list’s order, so a list does not reshuffle while a word is typed. An empty query keeps every row in order. - 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.
Type Aliases§
- Window
Group Id - One window group’s identity, as the desk numbers it.