⚠️ WARNING: This is no longer maintained nor works with current versions of Rust! Please use toml-rs instead.
A TOML configuration file parser for Rust.
Given the following TOML configuration file:
# products.toml
[global]
# ...
[db]
[[db.products]]
id = 1
name = "prod1"
[[db.products]]
id = 2
name = "prod2"
You can access it like in the example below:
extern crate toml = "github.com/mneumann/rust-toml#toml:0.1";
fn main() {
let root = toml::parse_from_file("products.toml").unwrap();
let id1 = root.lookup("db.products.0.id").get_int();
let name2 = root.lookup("db.products.1.name").get_str();
match (id1, name2) {
(Some(id1), Some(ref name2)) => {
println!("id1: {}, name2: {}", id1, name2)
}
_ => {
println!("Not found")
}
}
}
I did a pretty non-scientific benchmark against go-toml for a very large document (3 million lines). Not that it would matter in any way, but it shows that rust-toml is about three times as fast.
I am using this test suite to check for conformity to the TOML spec. The test cases are also included in this git repo, you can run them with this command:
./bin/testsuite ./tests
Alternatively you can run it with the test runner from the original test-suite using this command (see it's homepage for details on how to install it):
$HOME/go/local/bin/toml-test rust-toml/bin/testsuite
Right now all 63 tests pass, none fails.
rust-toml is under the MIT license, see LICENSE-MIT for details.
Copyright (c) 2014 by Michael Neumann.