pub struct MultiSourceConfig { /* private fields */ }Expand description
多源配置合并器:从文件、环境变量、远程配置中心收集配置并按优先级合并
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>)
设置文件来源配置
Sourcepub fn set_env_config(&mut self, config: HashMap<String, String>)
pub fn set_env_config(&mut self, config: HashMap<String, String>)
设置环境变量来源配置
Sourcepub fn set_remote_config(&mut self, config: HashMap<String, String>)
pub fn set_remote_config(&mut self, config: HashMap<String, String>)
设置远程配置中心来源配置
Sourcepub fn load_env_vars(&mut self, prefix: &str)
pub fn load_env_vars(&mut self, prefix: &str)
从系统环境变量加载配置(前缀过滤)
Sourcepub fn source_of(&self, key: &str) -> Option<ConfigSourcePriority>
pub fn source_of(&self, key: &str) -> Option<ConfigSourcePriority>
返回某个 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