pub struct Config { /* private fields */ }Expand description
Configuration manager with hierarchical support
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, UtilsError>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, UtilsError>
Load configuration from a file
Sourcepub fn load_environment(&mut self, prefix: &str) -> Result<(), UtilsError>
pub fn load_environment(&mut self, prefix: &str) -> Result<(), UtilsError>
Load environment variables with prefix
Sourcepub fn get(&self, key: &str) -> Option<&ConfigValue>
pub fn get(&self, key: &str) -> Option<&ConfigValue>
Get configuration value by key (supports dot notation)
Sourcepub fn set(&mut self, key: &str, value: ConfigValue)
pub fn set(&mut self, key: &str, value: ConfigValue)
Set configuration value
Sourcepub fn get_string(&self, key: &str, default: &str) -> String
pub fn get_string(&self, key: &str, default: &str) -> String
Get string value with default
Sourcepub fn to_json(&self) -> Result<String, UtilsError>
pub fn to_json(&self) -> Result<String, UtilsError>
Serialize configuration to JSON
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more