pub struct Config {
pub sections: BTreeMap<String, BTreeMap<String, String>>,
pub general_values: BTreeMap<String, String>,
}
Expand description
Represents an INI-style configuration, including both general values (not tied to any section) and sectioned key-value pairs.
You can build a Config
manually using the ConfigBuilder
API,
load one from a file, or create defaults using macros like
crate::sectioned_defaults!
and crate::general_defaults!
.
Fields§
§sections: BTreeMap<String, BTreeMap<String, String>>
§general_values: BTreeMap<String, String>
Implementations§
Source§impl Config
impl Config
pub fn general(&self) -> &BTreeMap<String, String>
pub fn get(&self, section: Option<&str>, key: &str) -> Option<String>
pub fn get_as<T>(&self, section: Option<&str>, key: &str) -> Option<T>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, Error>
pub fn load_or_default<P: AsRef<Path>>(path: P, default: Config) -> Self
pub fn load_or_default_outcome<P: AsRef<Path>>( path: P, default: Config, ) -> LoadOutcome
pub fn builder() -> ConfigBuilder
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<&Self, Error>
pub fn section(&self, title: &str) -> Option<&BTreeMap<String, String>>
pub fn sections(&self) -> &BTreeMap<String, BTreeMap<String, String>>
pub fn update( &mut self, section: Option<&str>, key: &str, value: &str, ) -> &mut Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Config
impl StructuralPartialEq for Config
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