pub struct MultiSourceConfig { /* private fields */ }Expand description
Multi-source configuration merger: collects configuration from files, environment variables, and a remote configuration center, then merges them by priority.
Implementations§
Source§impl MultiSourceConfig
impl MultiSourceConfig
pub fn new() -> Self
Sourcepub fn set_file_config(&mut self, config: HashMap<String, String>)
pub fn set_file_config(&mut self, config: HashMap<String, String>)
Set the file-source configuration
Sourcepub fn set_env_config(&mut self, config: HashMap<String, String>)
pub fn set_env_config(&mut self, config: HashMap<String, String>)
Set the environment-variable-source configuration
Sourcepub fn set_remote_config(&mut self, config: HashMap<String, String>)
pub fn set_remote_config(&mut self, config: HashMap<String, String>)
Set the remote configuration center source configuration
Sourcepub fn load_env_vars(&mut self, prefix: &str)
pub fn load_env_vars(&mut self, prefix: &str)
Load configuration from system environment variables (with prefix filtering)
Sourcepub fn load_json(&mut self, json: &str) -> Result<(), String>
pub fn load_json(&mut self, json: &str) -> Result<(), String>
Load configuration from JSON file content
Sourcepub fn merge(&self) -> HashMap<String, String>
pub fn merge(&self) -> HashMap<String, String>
Merge all sources and return the result (higher priority overrides lower)
Sourcepub fn source_of(&self, key: &str) -> Option<ConfigSourcePriority>
pub fn source_of(&self, key: &str) -> Option<ConfigSourcePriority>
Return the source priority of a key
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MultiSourceConfig
impl RefUnwindSafe for MultiSourceConfig
impl Send for MultiSourceConfig
impl Sync for MultiSourceConfig
impl Unpin for MultiSourceConfig
impl UnsafeUnpin for MultiSourceConfig
impl UnwindSafe for MultiSourceConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more