Crate tini[−][src]
Expand description
tini is a tiny ini-file parsing library
This small library provides basic functions to operate with ini-files.
Features:
- no dependencies;
- parsing from file, from reader and from string;
- convert parsed value to given type;
- parse comma-separated lists to vectors;
- construct new ini-structure with method chaining;
- writing to file, to writer and to string.
Examples
Read from buffer and get string values
let conf = Ini::from_string(["[search]",
"g = google.com",
"dd = duckduckgo.com"].join("\n")).unwrap();
let g: String = conf.get("search", "g").unwrap();
let dd: String = conf.get("search", "dd").unwrap();
assert_eq!(g, "google.com");
assert_eq!(dd, "duckduckgo.com");
Construct in program and get vectors
let conf = Ini::new().section("floats")
.item_vec("consts", &[3.1416, 2.7183])
.section("integers")
.item_vec("lost", &[4, 8, 15, 16, 23, 42]);
let consts: Vec<f64> = conf.get_vec("floats", "consts").unwrap();
let lost: Vec<i32> = conf.get_vec("integers", "lost").unwrap();
assert_eq!(consts, [3.1416, 2.7183]);
assert_eq!(lost, [4, 8, 15, 16, 23, 42]);
Structs
Structure for INI-file data
An iterator over the sections of an ini document
A mutable iterator over the sections of an ini document
Enums
Options for possible errors that may arise
Enum for storing one of the possible errors code. The associated value represents the row index where the error occurred.