Skip to content

Commit

Permalink
Merge pull request #166 from matthiasbeyer/builder
Browse files Browse the repository at this point in the history
Add Config::with_merged()
  • Loading branch information
matthiasbeyer authored Mar 17, 2021
2 parents a9ce652 + b886c4e commit 66e3f7d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit 66e3f7d

Please sign in to comment.