Skip to main content

SettingsSchema

Trait SettingsSchema 

pub trait SettingsSchema:
    Serialize
    + DeserializeOwned
    + Default
    + 'static {
    const SCOPE: Scope;
}
Expand description

A typed settings value with a declared Scope.

Reads never fail: a missing document reads as Default, and a key that is missing or does not decode reads as its default while every other key keeps its stored value. An app’s types of one scope share its section, so their field names must not collide.

ⓘ
#[derive(Clone, Default, PartialEq, Serialize, Deserialize)]
struct Preferences { confirm_kill: bool }
impl SettingsSchema for Preferences {
    const SCOPE: Scope = Scope::Personal;
}
let prefs = context.settings::<Preferences>().get();

Required Associated Constants§

const SCOPE: Scope

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§