summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-14 08:58:40 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-03-14 08:58:40 +0100
commit9802e2f47e3d643d353224af0c2e6667b2dfa170 (patch)
tree5682d5a6da9ddfbe6495322d09f904d82c00e171
parent05b04b8a9982154b1f0755c0b4e0eb2cb3d88235 (diff)
parente701e0071910169e4e21d3d5331a18aaecedb78b (diff)
downloadconfig-maint-9802e2f47e3d643d353224af0c2e6667b2dfa170.tar.gz
config-maint-9802e2f47e3d643d353224af0c2e6667b2dfa170.tar.xz
Merge branch 'builder'
-rw-r--r--src/config.rs22
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.
///