Add tini
to your Cargo.toml
, for example:
toml
[dependencies]
tini = "1.3"
```rust extern crate tini; use tini::Ini;
fn main() {
// Read example.ini file from examples directory
let config = Ini::fromfile("./examples/example.ini").unwrap();
// Read name3 key from sectionone
let name3: String = config.get("sectionone", "name3").unwrap();
// Read list of values
let frst5: Vec
```rust extern crate tini; use tini::Ini;
fn main() {
// Create ini structure
let conf = Ini::new() // initialize Ini
.section("params") // create params
section
.item("pi", 3.14) // add pi
key
.itemvec("lost", &[4, 8, 15, 16, 23, 42]) // add lost
list
.section("other") // create another section
.item("default", "hello world!"); // add default
key to other
section
// At any time you can add new parameters to the last created section
// < some code >
// Now write ini structure to file
conf.tofile("output.ini").unwrap();
// Now output.ini
contains
// -----------------------------
// [params]
// pi = 3.14
// lost = 4, 8, 15, 16, 23, 42
//
// [other]
// default = hello world!
// -----------------------------
}
```
See more examples in documentation.