General code for load/store settings

This commit is contained in:
daa84
2017-10-19 17:04:58 +03:00
parent fbe25e1a1c
commit a286d39b48
5 changed files with 142 additions and 84 deletions

View File

@@ -1,9 +1,40 @@
pub struct Store {
}
use toml;
use settings::SettingsLoader;
pub struct Store {}
impl Store {
pub fn new() -> Self {
Store { }
Store {}
}
}
#[derive(Serialize, Deserialize)]
struct Settings {
plugs: Vec<PlugInfo>,
}
impl SettingsLoader for Settings {
const SETTINGS_FILE: &'static str = "plugs.toml";
fn empty() -> Self {
Settings { plugs: vec![] }
}
fn from_str(s: &str) -> Result<Self, String> {
toml::from_str(&s).map_err(|e| format!("{}", e))
}
}
#[derive(Serialize, Deserialize)]
pub struct PlugInfo {
name: String,
url: String,
}
impl PlugInfo {
pub fn new(name: String, url: String) -> Self {
PlugInfo { name, url }
}
}