use std::collections::HashMap;
#[non_exhaustive]
pub struct UserSetting {
pub key: Box<str>,
pub description: Box<str>,
pub default_value: SettingValue,
}
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum SettingValue {
Bool(bool),
}
#[derive(Clone, Default)]
pub struct SettingsStore {
values: HashMap<Box<str>, SettingValue>,
}
impl SettingsStore {
pub fn new() -> Self {
Self::default()
}
pub fn set(&mut self, key: Box<str>, value: SettingValue) {
self.values.insert(key, value);
}
pub fn get(&self, key: &str) -> Option<&SettingValue> {
self.values.get(key)
}
pub fn iter(&self) -> impl Iterator<Item = (&str, &SettingValue)> {
self.values.iter().map(|(k, v)| (k.as_ref(), v))
}
}