diff --git a/src/config.rs b/src/config.rs index feaf51ca..df6da054 100644 --- a/src/config.rs +++ b/src/config.rs @@ -64,23 +64,29 @@ impl fmt::Display for ConfigValue { } } -const DEFAULT_CONFIG: LazyCell>> = +pub(crate) const DEFAULT_CONFIG: LazyCell>> = LazyCell::new(|| HashMap::new()); pub(crate) struct Config<'a> { filename: PathBuf, - defaults: LazyCell>>, + defaults: HashMap<&'a str, HashMap<&'a str, ConfigValue>>, + default_section: &'a str, ini: Ini, } -impl Config<'static> { +impl<'a> Config<'a> { /// Create a new Config object - pub(crate) fn new>(filename: P) -> Self { + pub(crate) fn new>( + filename: P, + defaults: HashMap<&'a str, HashMap<&'a str, ConfigValue>>, + default_section: Option<&'a str>, + ) -> Self { // TODO: read ini file. Config { filename: filename.into(), - defaults: DEFAULT_CONFIG, + defaults, + default_section: default_section.unwrap_or("default"), ini: Ini::new(), } }