Skip to main content

SettingsStore

Trait SettingsStore 

Source
pub trait SettingsStore: Send + Sync {
    // Required methods
    fn scopes(&self) -> Vec<ValueScope>;
    fn load(&self, scope: ValueScope) -> Result<Values, String>;
    fn save(&self, scope: ValueScope, changes: &Changes) -> Result<(), String>;

    // Provided methods
    fn claims(&self, _setting: &str) -> bool { ... }
    fn watch(
        &self,
        _scope: ValueScope,
        _on_change: OnChange,
    ) -> Result<(), String> { ... }
    fn problems(&self) -> Vec<String> { ... }
}
Expand description

Where the settings are kept, as the host provides it. Every method may be called from a thread other than the UI’s: save always is, except on the web.

Required Methods§

Source

fn scopes(&self) -> Vec<ValueScope>

The scopes it keeps (app, and host scopes such as a library).

Source

fn load(&self, scope: ValueScope) -> Result<Values, String>

A scope’s values as kept now.

Source

fn save(&self, scope: ValueScope, changes: &Changes) -> Result<(), String>

Keeps the values that changed in a scope. Never called on the UI thread (but on the web).

Provided Methods§

Source

fn claims(&self, _setting: &str) -> bool

Whether it keeps this setting (by id). Everything by default.

Source

fn watch(&self, _scope: ValueScope, _on_change: OnChange) -> Result<(), String>

Follows the changes made elsewhere to a scope: on_change is called with them. Stores that see none keep the default.

Source

fn problems(&self) -> Vec<String>

Problems worth showing in the Settings window that are not a failed load or save (a setting two handlers claim).

Implementors§