SuggestStore

The store is the entry point to the Suggest component. It incrementally downloads suggestions from the Remote Settings service, stores them in a local database, and returns them in response to user queries.

Your application should create a single store, and manage it as a singleton. The store is thread-safe, and supports concurrent queries and ingests. We expect that your application will call `SuggestStore::query()` to show suggestions as the user types into the address bar, and periodically call `SuggestStore::ingest()` in the background to update the database with new suggestions from Remote Settings.

For responsiveness, we recommend always calling query() on a worker thread. When the user types new input into the address bar, call `SuggestStore::interrupt()` on the main thread to cancel the query for the old input, and unblock the worker thread for the new query.

The store keeps track of the state needed to support incremental ingestion, but doesn't schedule the ingestion work itself, or decide how many suggestions to ingest at once. This is for two reasons:

  1. The primitives for scheduling background work vary between platforms, and aren't available to the lower-level Rust layer. You might use an idle timer on Desktop, WorkManager on Android, or BGTaskScheduler on iOS.

  2. Ingestion constraints can change, depending on the platform and the needs of your application. A mobile device on a metered connection might want to request a small subset of the Suggest data and download the rest later, while a desktop on a fast link might download the entire dataset on the first launch.

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class>)
constructor(noPointer: NoPointer)

This constructor can be used to instantiate a fake object. Only used for tests. Any attempt to actually use an object constructed this way will fail as there is no connected Rust object.

constructor(path: String, settingsConfig: RemoteSettingsConfig? = null)

Creates a Suggest store.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun clear()

Removes all content from the database.

Link copied to clipboard
open override fun clearDismissedSuggestions()

Clear dismissed suggestions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun destroy()
Link copied to clipboard
open override fun dismissSuggestion(suggestionUrl: String)

Dismiss a suggestion

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Ingests new suggestions from Remote Settings.

Link copied to clipboard
open override fun interrupt(kind: InterruptKind?)

Interrupts any ongoing queries.

Link copied to clipboard
open override fun query(query: SuggestionQuery): List<Suggestion>

Queries the database for suggestions.

Link copied to clipboard

Queries the database for suggestions.

Link copied to clipboard
fun uniffiClonePointer(): <Error class: unknown class>