pub struct Config {
pub sections: BTreeMap<String, BTreeMap<String, String>>,
pub general_values: BTreeMap<String, String>,
}Fields§
§sections: BTreeMap<String, BTreeMap<String, String>>§general_values: BTreeMap<String, String>Implementations§
source§impl Config
impl Config
pub fn get(&self, section: Option<&str>, key: &str) -> Option<&String>
sourcepub fn new<'a>() -> ConfigBuilder<'a>
pub fn new<'a>() -> ConfigBuilder<'a>
Examples found in repository?
More examples
examples/sectioned_manual.rs (line 4)
3 4 5 6 7 8 9 10 11 12 13 14 15 16
fn main() -> Result<(), config_tools::Error> {
let config = Config::new()
.section("Server")
.set("host", "127.0.0.1")
.set("port", "8080")
.section("Window")
.set("width", "720")
.set("height", "480")
.general()
.set("console", "true")
.build();
config.save("config-sectioned-manual.ini")
}sourcepub fn save(&self, filename: &str) -> Result<(), Error>
pub fn save(&self, filename: &str) -> Result<(), Error>
Examples found in repository?
More examples
examples/sectioned_manual.rs (line 15)
3 4 5 6 7 8 9 10 11 12 13 14 15 16
fn main() -> Result<(), config_tools::Error> {
let config = Config::new()
.section("Server")
.set("host", "127.0.0.1")
.set("port", "8080")
.section("Window")
.set("width", "720")
.set("height", "480")
.general()
.set("console", "true")
.build();
config.save("config-sectioned-manual.ini")
}examples/sectioned_macro.rs (line 20)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() -> Result<(), config_tools::Error> {
let mut config = config_tools::sectioned_defaults! {
{
"console" => "true"
}
["Application"] {
"host" => "127.0.0.1",
"port" => "8080",
}
["Window"] {
"width" => "720",
"height" => "480",
}
};
config.update(Some("Application"), "host", "0.0.0.0");
config.save("config-sectioned-macro.ini")
}pub fn sections(&self) -> &BTreeMap<String, BTreeMap<String, String>>
sourcepub fn update(&mut self, section: Option<&str>, key: &str, value: &str)
pub fn update(&mut self, section: Option<&str>, key: &str, value: &str)
Examples found in repository?
More examples
examples/sectioned_macro.rs (line 18)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() -> Result<(), config_tools::Error> {
let mut config = config_tools::sectioned_defaults! {
{
"console" => "true"
}
["Application"] {
"host" => "127.0.0.1",
"port" => "8080",
}
["Window"] {
"width" => "720",
"height" => "480",
}
};
config.update(Some("Application"), "host", "0.0.0.0");
config.save("config-sectioned-macro.ini")
}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
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