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, they declare what they 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.
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 modifier held, 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.
BodyPiece
One contiguous run of body text.
CommandRow
The slots of a SearchRow::Command row 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: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.
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.
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.
RowFace
One person in a row’s face stack (CommandRow::faces).
ScopeDecl
SearchBody
A body attached to a SearchRecord.
SearchButton
search_button for the whole app, made from its description.
SearchButtonProps
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.
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.
SearchOffer
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.
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.
SearchPreview
The preview of one search hit.
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§

ActivationModifier
A modifier held while a row is activated, choosing an alternative activation the row offers (CommandRow::alternates).
MatchTier
How strongly a query matched one field; later variants are stronger.
PagePoll
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.
SearchCatalogError
SearchRow
The shape of one search hit’s row.

Constants§

APP_SEARCH_BUTTON_ID
The id of the button search_button makes 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::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.
PREVIEW_BODY_LINES
How many lines the band wraps a SearchPreview::body over.
PREVIEW_LINES
How many SearchPreview::lines the band shows.

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§

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) to out.
fold_search_text
Fold complete text.
initials
The first letters of a title’s words, folded: Word Processor is wp, so the two letters typed for it find it. None for a title of one word, which has nothing to abbreviate.
is_search_address
Whether address names the host search door.
locate
The byte range in raw text, a field of weight, of the occurrence of query the index matches there under folding: the first one starting a word, or inside a word where a field of weight matches 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. None where 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_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.
ranked_rows
The rows of a short list that answer query, best first, ranked by index the 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 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.

Type Aliases§

WindowGroupId
One window group’s identity, as the desk numbers it.