refactor global config model

This commit is contained in:
Sebastian Hugentobler 2017-05-04 16:21:07 +02:00
parent dcbd44a752
commit 4b322b500f

View File

@ -30,6 +30,10 @@ fn timestamp() -> i64 {
UTC::now().timestamp() UTC::now().timestamp()
} }
fn default_list() -> Vec<String> {
Vec::new()
}
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Config { pub struct Config {
@ -37,12 +41,6 @@ pub struct Config {
pub game_storage: String, pub game_storage: String,
#[serde(default)] #[serde(default)]
pub movie_storage: String, pub movie_storage: String,
#[serde(default = "default_map")]
pub content: HashMap<String, u64>,
#[serde(default = "default_map")]
pub data: HashMap<String, u64>,
#[serde(default = "default_map")]
pub extras: HashMap<String, u64>,
#[serde(default = "default_list")] #[serde(default = "default_list")]
pub os_filters: Vec<String>, pub os_filters: Vec<String>,
#[serde(default = "default_list")] #[serde(default = "default_list")]
@ -55,22 +53,11 @@ pub struct Config {
pub skip_games: bool, pub skip_games: bool,
} }
fn default_map() -> HashMap<String, u64> {
HashMap::new()
}
fn default_list() -> Vec<String> {
Vec::new()
}
impl Config { impl Config {
pub fn new() -> Config { pub fn new() -> Config {
Config { Config {
game_storage: String::from("."), game_storage: String::from("."),
movie_storage: String::from("."), movie_storage: String::from("."),
content: HashMap::new(),
data: HashMap::new(),
extras: HashMap::new(),
os_filters: Vec::new(), os_filters: Vec::new(),
language_filters: Vec::new(), language_filters: Vec::new(),
resolution_filters: Vec::new(), resolution_filters: Vec::new(),