Crates.io | gtoml |
lib.rs | gtoml |
version | |
source | src |
created_at | 2025-03-23 06:15:26.975028+00 |
updated_at | 2025-03-23 06:19:47.642266+00 |
description | Get TOML values quickly |
homepage | http://dnrops.gitlink.net |
repository | https://gitlab.com/andrew_ryan/gtoml |
max_upload_size | |
id | 1602375 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Get TOML values quickly
gtoml is a Rust crate that offers a fast and simple way to retrieve values from a TOML document. It comes with features such as one-line retrieval, dot notation paths, and iteration.
Add the following to your Cargo.toml
:
[dependencies]
gtoml = "0.1"
This is a Rust library designed to parse TOML strings and retrieve values based on specified paths. It supports basic TOML parsing, path-based value lookup, array length retrieval, and wildcard matching.
toml::Value
type.Value
using a specified path.*
and ?
wildcards in the path for matching.use toml::Value;
use gtoml::parse;
let toml_str = r#"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00Z
"#;
let value = parse(toml_str).unwrap();
use toml::Value;
use gtoml::{parse, get};
let toml_str = r#"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00Z
"#;
let value = parse(toml_str).unwrap();
let result = get(&value, "owner.name").unwrap();
use toml::Value;
use gtoml::get_from_str;
let toml_str = r#"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00Z
"#;
let result = get_from_str(toml_str, "owner.name").unwrap();
You can use *
and ?
wildcards in the path for matching:
use toml::Value;
use gtoml::{parse, get};
let toml_str = r#"
children = ["Sara", "Alex", "Jack"]
"#;
let value = parse(toml_str).unwrap();
let result = get(&value, "child*").unwrap();
To get the length of an array, use #
in the path:
use toml::Value;
use gtoml::{parse, get};
let toml_str = r#"
children = ["Sara", "Alex", "Jack"]
"#;
let value = parse(toml_str).unwrap();
let result = get(&value, "children.#").unwrap();
This library includes a series of test cases. You can run the tests with the following command:
cargo test