Populate created local settings file with an empty JSON object and comments
This commit is contained in:
parent
cb975f1252
commit
296a0bf510
5 changed files with 55 additions and 20 deletions
|
@ -9,10 +9,23 @@ pub use settings_store::{Setting, SettingsJsonSchemaParams, SettingsStore};
|
|||
use std::{borrow::Cow, str};
|
||||
|
||||
pub const DEFAULT_SETTINGS_ASSET_PATH: &str = "settings/default.json";
|
||||
pub const INITIAL_USER_SETTINGS_ASSET_PATH: &str = "settings/initial_user_settings.json";
|
||||
const INITIAL_USER_SETTINGS_ASSET_PATH: &str = "settings/initial_user_settings.json";
|
||||
const INITIAL_LOCAL_SETTINGS_ASSET_PATH: &str = "settings/initial_local_settings.json";
|
||||
|
||||
pub fn initial_user_settings_content(assets: &'static impl AssetSource) -> Cow<'static, str> {
|
||||
match assets.load(INITIAL_USER_SETTINGS_ASSET_PATH).unwrap() {
|
||||
pub fn default_settings() -> Cow<'static, str> {
|
||||
asset_str(&assets::Assets, DEFAULT_SETTINGS_ASSET_PATH)
|
||||
}
|
||||
|
||||
pub fn initial_user_settings_content(assets: &dyn AssetSource) -> Cow<'_, str> {
|
||||
asset_str(assets, INITIAL_USER_SETTINGS_ASSET_PATH)
|
||||
}
|
||||
|
||||
pub fn initial_local_settings_content(assets: &dyn AssetSource) -> Cow<'_, str> {
|
||||
asset_str(assets, INITIAL_LOCAL_SETTINGS_ASSET_PATH)
|
||||
}
|
||||
|
||||
fn asset_str<'a>(assets: &'a dyn AssetSource, path: &str) -> Cow<'a, str> {
|
||||
match assets.load(path).unwrap() {
|
||||
Cow::Borrowed(s) => Cow::Borrowed(str::from_utf8(s).unwrap()),
|
||||
Cow::Owned(s) => Cow::Owned(String::from_utf8(s).unwrap()),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue