diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-14 08:58:40 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-14 08:58:40 +0100 |
commit | 9802e2f47e3d643d353224af0c2e6667b2dfa170 (patch) | |
tree | 5682d5a6da9ddfbe6495322d09f904d82c00e171 /src/config.rs | |
parent | 05b04b8a9982154b1f0755c0b4e0eb2cb3d88235 (diff) | |
parent | e701e0071910169e4e21d3d5331a18aaecedb78b (diff) |
Merge branch 'builder'
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index e6da482..1019061 100644 --- a/src/config.rs +++ b/src/config.rs @@ -78,6 +78,28 @@ impl Config { self.refresh() } + /// Merge in a configuration property source. + pub fn with_merged<T>(mut self, source: T) -> Result<Self> + where + T: 'static, + T: Source + Send + Sync, + { + match self.kind { + ConfigKind::Mutable { + ref mut sources, .. + } => { + sources.push(Box::new(source)); + } + + ConfigKind::Frozen => { + return Err(ConfigError::Frozen); + } + } + + self.refresh()?; + Ok(self) + } + /// Refresh the configuration cache with fresh /// data from added sources. /// |