diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 43 | ||||
-rw-r--r-- | src/model.rs | 3 |
2 files changed, 6 insertions, 40 deletions
diff --git a/src/config.rs b/src/config.rs index bbe6366..3eb0dd4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,7 +7,7 @@ use serde_derive; use std::collections::HashMap; use std::path::PathBuf; -#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] +#[derive(serde_derive::Deserialize)] #[serde(deny_unknown_fields)] pub struct Source { pub name: String, @@ -19,7 +19,7 @@ pub struct Source { pub required: bool, } -#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] +#[derive(serde_derive::Deserialize)] #[serde(deny_unknown_fields)] pub struct Peer { pub source: Option<String>, @@ -28,7 +28,6 @@ pub struct Peer { pub keepalive: Option<u32>, } -#[derive(Clone, PartialEq, Eq, Debug)] pub struct GlobalConfig { pub min_keepalive: u32, pub max_keepalive: u32, @@ -58,7 +57,6 @@ impl GlobalConfig { } } -#[derive(Clone, PartialEq, Eq, Debug)] pub struct UpdaterConfig { pub cache_directory: Option<PathBuf>, @@ -76,8 +74,9 @@ impl Default for UpdaterConfig { } } -#[derive(serde_derive::Serialize, serde_derive::Deserialize, Default, Clone, Debug)] -#[serde(from = "ConfigRepr", into = "ConfigRepr")] +#[derive(serde_derive::Deserialize)] +#[serde(from = "ConfigRepr")] +#[derive(Default)] pub struct Config { pub runtime_directory: Option<PathBuf>, pub global: GlobalConfig, @@ -85,7 +84,7 @@ pub struct Config { pub sources: Vec<Source>, } -#[derive(serde_derive::Serialize, serde_derive::Deserialize)] +#[derive(serde_derive::Deserialize)] #[serde(deny_unknown_fields)] struct ConfigRepr { runtime_directory: Option<PathBuf>, @@ -105,36 +104,6 @@ struct ConfigRepr { sources: Vec<Source>, } -impl From<Config> for ConfigRepr { - #[inline] - fn from(v: Config) -> Self { - let Config { - runtime_directory, - global, - updater, - sources, - } = v; - let GlobalConfig { - min_keepalive, - max_keepalive, - peers, - } = global; - let UpdaterConfig { - cache_directory, - refresh_sec, - } = updater; - Self { - runtime_directory, - cache_directory, - min_keepalive, - max_keepalive, - peers, - refresh_sec, - sources, - } - } -} - impl From<ConfigRepr> for Config { #[inline] fn from(v: ConfigRepr) -> Self { diff --git a/src/model.rs b/src/model.rs index 1f537bc..5797f0e 100644 --- a/src/model.rs +++ b/src/model.rs @@ -2,9 +2,6 @@ // // Copyright 2019 Hristo Venev -// FIXME: arrayref needs to silence this per-expression -#![allow(clippy::eval_order_dependence)] - use base64; use std::collections::HashMap; use std::fmt; |