tini — A tiny INI parsing library
Usage
Add tini
to your Cargo.toml
, for example:
[dependencies]
tini = "1.3"
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_vec("lost", &[4, 8, 15, 16, 23, 42]) .section("other") .item("default", "hello world!"); conf.to_file("output.ini").unwrap();
}
See more examples in documentation.