Skip to main content

MultiSourceConfig

Struct MultiSourceConfig 

Source
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

Source

pub fn new() -> Self

Source

pub fn set_file_config(&mut self, config: HashMap<String, String>)

Set the file-source configuration

Source

pub fn set_env_config(&mut self, config: HashMap<String, String>)

Set the environment-variable-source configuration

Source

pub fn set_remote_config(&mut self, config: HashMap<String, String>)

Set the remote configuration center source configuration

Source

pub fn load_env_vars(&mut self, prefix: &str)

Load configuration from system environment variables (with prefix filtering)

Source

pub fn load_json(&mut self, json: &str) -> Result<(), String>

Load configuration from JSON file content

Source

pub fn merge(&self) -> HashMap<String, String>

Merge all sources and return the result (higher priority overrides lower)

Source

pub fn get(&self, key: &str) -> Option<String>

Get the merged configuration value

Source

pub fn source_of(&self, key: &str) -> Option<ConfigSourcePriority>

Return the source priority of a key

Trait Implementations§

Source§

impl Default for MultiSourceConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.