diff options
author | Hristo Venev <hristo@venev.name> | 2019-09-28 16:20:06 +0000 |
---|---|---|
committer | Hristo Venev <hristo@venev.name> | 2019-09-28 16:20:43 +0000 |
commit | 3a5552509439612accf579becc7cb85a596bd466 (patch) | |
tree | cbb6af2c4217e1ac6c57f904c9de2976e72b052d /src/config.rs | |
parent | b20d7f8b89f5e4b065b0a3fee52ece8db6f99a74 (diff) |
PeerConfig -> GlobalConfig
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/config.rs b/src/config.rs index 98a795f..ccdb042 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,14 +20,14 @@ pub struct Source { #[serde(deny_unknown_fields)] #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] -pub struct PeerConfig { +pub struct GlobalConfig { #[serde(default = "default_min_keepalive")] pub min_keepalive: u32, #[serde(default = "default_max_keepalive")] pub max_keepalive: u32, } -impl Default for PeerConfig { +impl Default for GlobalConfig { #[inline] fn default() -> Self { Self { @@ -37,6 +37,18 @@ impl Default for PeerConfig { } } +impl GlobalConfig { + pub fn fix_keepalive(&self, mut k: u32) -> u32 { + if self.max_keepalive != 0 && (k == 0 || k > self.max_keepalive) { + k = self.max_keepalive; + } + if k != 0 && k < self.min_keepalive { + k = self.min_keepalive; + } + k + } +} + #[serde(deny_unknown_fields)] #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] pub struct UpdaterConfig { @@ -63,7 +75,7 @@ pub struct Config { pub runtime_directory: Option<PathBuf>, #[serde(flatten)] - pub peer_config: PeerConfig, + pub global: GlobalConfig, #[serde(flatten)] pub updater: UpdaterConfig, @@ -72,18 +84,6 @@ pub struct Config { pub sources: HashMap<String, Source>, } -impl PeerConfig { - pub fn fix_keepalive(&self, mut k: u32) -> u32 { - if self.max_keepalive != 0 && (k == 0 || k > self.max_keepalive) { - k = self.max_keepalive; - } - if k != 0 && k < self.min_keepalive { - k = self.min_keepalive; - } - k - } -} - #[inline] const fn default_min_keepalive() -> u32 { 10 |