tini — A tiny INI parsing library, written in Rust
| Documentation | Examples |
Usage
Add tini
to your Cargo.toml
, for example:
[dependencies]
tini = "0.4"
How to use
Read ini configuration from file
extern crate tini;
use tini::Ini;
fn main() {
let config = Ini::from_file("./examples/example.ini").unwrap();
let name3: String = config.get("section_one", "name3").unwrap();
let frst5: Vec<bool> = config.get_vec("section_three", "frst5").unwrap();
println!("name3 = {}", name3);
println!("frst5 = {:?}", frst5);
}
Create ini configuration and write to file
extern crate tini;
use tini::Ini;
fn main() {
let conf = Ini::new() .section("params") .item("pi", "3.14") .item("lost", "4, 8, 15, 16, 23, 42") .section("other") .item("default", "hello world!"); conf.to_file("output.ini").unwrap();
}
See more in examples folder or in documentation.