diff --git a/core/dtn7/src/dtnconfig.rs b/core/dtn7/src/dtnconfig.rs index 76e527e4..e2f39862 100644 --- a/core/dtn7/src/dtnconfig.rs +++ b/core/dtn7/src/dtnconfig.rs @@ -64,13 +64,18 @@ pub fn rnd_node_name() -> String { impl From for DtnConfig { fn from(item: PathBuf) -> Self { let mut dtncfg = DtnConfig::new(); - let mut s = Config::default(); + let s_default = Config::default(); + + let configbuilder = Config::builder().add_source(s_default); debug!("Loading config: {}", item.to_str().unwrap()); // Start off by merging in the "default" configuration file - s.merge(File::new(item.to_str().unwrap(), config::FileFormat::Toml)) + let s = configbuilder + .add_source(File::new(item.to_str().unwrap(), config::FileFormat::Toml)) + .build() .unwrap(); + dtncfg.debug = s.get_bool("debug").unwrap_or(false); if dtncfg.debug { //std::env::set_var("RUST_LOG", "dtn7=debug,dtnd=debug"); diff --git a/core/dtn7/tests/config-test.rs b/core/dtn7/tests/config-test.rs index f23bc9c9..f1941c1b 100644 --- a/core/dtn7/tests/config-test.rs +++ b/core/dtn7/tests/config-test.rs @@ -2,14 +2,16 @@ use config::{Config, File}; #[test] fn config_test() { - let mut s = Config::default(); - // Start off by merging in the "default" configuration file - s.merge(File::new( - "../../examples/dtn7.toml.example", - config::FileFormat::Toml, - )) - .unwrap(); + let s = Config::builder() + .add_source(Config::default()) + .add_source(File::new( + "../../examples/dtn7.toml.example", + config::FileFormat::Toml, + )) + .build() + .unwrap(); + println!("{:?}", s); println!("debug: {:?}", s.get_bool("debug").unwrap_or(false));