summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 888d8cc..f4d21d5 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.
///