pub trait Settings: 'static + Send + Sync {
type FileContent: Clone + Default + Serialize + DeserializeOwned + JsonSchema;
const KEY: Option<&'static str>;
// Required method
fn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
cx: &mut AppContext
) -> Result<Self>
where Self: Sized;
// Provided methods
fn json_schema(
generator: &mut SchemaGenerator,
_: &SettingsJsonSchemaParams<'_>,
_: &AppContext
) -> RootSchema { ... }
fn json_merge(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent]
) -> Result<Self::FileContent> { ... }
fn load_via_json_merge(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent]
) -> Result<Self>
where Self: DeserializeOwned { ... }
fn missing_default() -> Error { ... }
fn register(cx: &mut AppContext)
where Self: Sized { ... }
fn get<'a>(path: Option<(usize, &Path)>, cx: &'a AppContext) -> &'a Self
where Self: Sized { ... }
fn get_global<'a>(cx: &'a AppContext) -> &'a Self
where Self: Sized { ... }
fn override_global<'a>(settings: Self, cx: &'a mut AppContext)
where Self: Sized { ... }
}
Expand description
A value that can be defined as a user setting.
Settings can be loaded from a combination of multiple JSON files.
Required Associated Types§
sourcetype FileContent: Clone + Default + Serialize + DeserializeOwned + JsonSchema
type FileContent: Clone + Default + Serialize + DeserializeOwned + JsonSchema
The type that is stored in an individual JSON file.
Required Associated Constants§
Required Methods§
sourcefn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
cx: &mut AppContext
) -> Result<Self>where
Self: Sized,
fn load( default_value: &Self::FileContent, user_values: &[&Self::FileContent], cx: &mut AppContext ) -> Result<Self>where Self: Sized,
The logic for combining together values from one or more JSON files into the final value for this setting.
The user values are ordered from least specific (the global settings file) to most specific (the innermost local settings file).