From 84f4aa9be3b7408935c1efac66946955e27a7d89 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 26 Feb 2022 16:22:36 +0100 Subject: [PATCH] Migrate to config v0.12.0 --- src/config.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index 1aa0671..9b6f706 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,21 +18,16 @@ pub struct Settings { } impl Settings { - #[deprecated] - pub fn new() -> Result { - Self::load() - } - pub fn load() -> Result { - let mut config = Config::new(); - config - .merge(File::with_name("hoc.toml").required(false))? - .merge(Environment::with_prefix("hoc"))? + Config::builder() + .add_source(File::with_name("hoc.toml").required(false)) + .add_source(Environment::with_prefix("hoc")) .set_default("repodir", "./repos")? .set_default("cachedir", "./cache")? .set_default("workers", 4)? .set_default("port", 8080)? - .set_default("host", "0.0.0.0")?; - config.try_into() + .set_default("host", "0.0.0.0")? + .build()? + .try_deserialize() } }