This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
OptionWriter
Ivan Semenkov edited this page Feb 4, 2021
·
1 revision
- About
- delete
- create_section
- create_array
- create_list
- write_int32
- write_int64
- write_float64
- write_bool
- write_string
It is writer for configuration option.
pub struct OptionWriter
Delete current config element.
pub fn delete(&self) -> Result<()>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("group") {
Some(group) => {
if !group.delete().is_ok() {
}
},
None => { /* ... */ }
}
Create new group section.
pub fn create_section<S>(&self, path : S) -> Option<OptionWriter>
where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("root.group") {
Some(s) => { /* ... */ },
None => { /* ... */ }
}
Create new array group section.
pub fn create_array<S>(&self, path : S) -> Option<CollectionWriter>
where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("array") {
Some(s) => { /* ... */ },
None => { /* ... */ }
}
Create new list group section.
pub fn create_list<S>(&self, path : S) -> Option<CollectionWriter>
where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_list("root.list") {
Some(s) => { /* ... */ },
None => { /* ... */ }
}
Add new integer value to current group.
pub fn write_int32<S>(&self, name : S, value : i32) ->
Option<OptionWriter> where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("section") {
Some(s) => {
s.write_int32("ival", 321);
},
None => { /* ... */ }
}
Add new int64 value to current group.
pub fn write_int64<S>(&self, name : S, value : i64) ->
Option<OptionWriter> where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("section") {
Some(s) => {
s.write_int64("ival", 321000);
},
None => { /* ... */ }
}
Add new float value to current group.
pub fn write_float64<S>(&self, name : S, value : f64) ->
Option<OptionWriter> where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("section") {
Some(s) => {
s.write_float64("ival", 321.001);
},
None => { /* ... */ }
}
Add new boolean value to current group.
pub fn write_bool<S>(&self, name : S, value : bool) ->
Option<OptionWriter> where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("section") {
Some(s) => {
s.write_bool("ival", false);
},
None => { /* ... */ }
}
Add new string value to current group.
pub fn write_string<S>(&self, name : S, value : S) ->
Option<OptionWriter> where S: Into<String>
use librustconfig::config::Config;
let cfg = Config::new();
match cfg.create_section("section") {
Some(s) => {
s.write_string("ival", "test string");
},
None => { /* ... */ }
}