diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index 53f0dab..f861e4d 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -39,6 +39,7 @@ pub trait Config { pub trait ConfigStore { fn default(&self) -> &dyn Config; fn active<'a>(&'a self, app: &AppProperties) -> &'a dyn Config; + fn configs(&self) -> Vec<&dyn Config>; fn get_all_match_paths(&self) -> HashSet; } diff --git a/espanso-config/src/config/store.rs b/espanso-config/src/config/store.rs index 1a7e483..76016d1 100644 --- a/espanso-config/src/config/store.rs +++ b/espanso-config/src/config/store.rs @@ -42,6 +42,17 @@ impl ConfigStore for DefaultConfigStore { self.default.as_ref() } + fn configs(&self) -> Vec<&dyn Config> { + let mut configs = Vec::new(); + + configs.push(self.default.as_ref()); + for custom in self.customs.iter() { + configs.push(custom.as_ref()); + } + + configs + } + // TODO: test fn get_all_match_paths(&self) -> HashSet { let mut paths = HashSet::new(); @@ -108,10 +119,7 @@ impl DefaultConfigStore { } pub fn from_configs(default: Box, customs: Vec>) -> Result { - Ok(Self { - default, - customs, - }) + Ok(Self { default, customs }) } }