suggest/
config.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 */
5
6use serde::{Deserialize, Serialize};
7
8use crate::rs::DownloadedGlobalConfig;
9
10/// Global Suggest configuration data.
11#[derive(Clone, Default, Debug, Deserialize, Serialize, PartialEq, Eq, uniffi::Record)]
12pub struct SuggestGlobalConfig {
13    pub show_less_frequently_cap: i32,
14}
15
16impl From<&DownloadedGlobalConfig> for SuggestGlobalConfig {
17    fn from(config: &DownloadedGlobalConfig) -> Self {
18        Self {
19            show_less_frequently_cap: config.configuration.show_less_frequently_cap,
20        }
21    }
22}
23
24/// Per-provider configuration data.
25#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, uniffi::Enum)]
26pub enum SuggestProviderConfig {
27    Weather {
28        /// Weather suggestion score.
29        score: f64,
30        /// Threshold for weather keyword prefix matching when a weather keyword
31        /// is the first term in a query. Zero means prefix matching is disabled
32        /// and weather keywords must be typed in full when they are first in
33        /// the query. (Ideally this would be an `Option` and `None` would mean
34        /// full keywords are required, but it's probably not worth the breaking
35        /// API change.) This threshold does not apply to city and region names.
36        min_keyword_length: i32,
37    },
38}