Expand description
§use-toml
Practical TOML utility primitives for lightweight table, key, and string handling.
Warning: versions below
0.3.0are experimental and may change as the crate matures.
§Example Usage
use use_toml::{extract_toml_key_values, extract_toml_tables, quote_toml_string};
let tables = extract_toml_tables("[package]\nname = \"use-data\"\n");
let values = extract_toml_key_values("name = \"use-data\"\npublish = false\n");
assert_eq!(tables[0].name, "package");
assert_eq!(values[0].key, "name");
assert_eq!(quote_toml_string("line\nbreak"), "\"line\\nbreak\"");§Scope
- table and array-table detection
- conservative key-value splitting without a full TOML parser
- small string quoting and unquoting helpers
§Non-Goals
- a full TOML parser
- Cargo-specific manifest logic
- full TOML type-system support
§License
Licensed under either of the following, at your option:
- MIT License
- Apache License, Version 2.0
Structs§
- Toml
KeyValue - A discovered TOML key-value pair.
- Toml
Table - A discovered TOML table header.
Functions§
- extract_
toml_ key_ values - Extracts TOML key-value pairs from the input.
- extract_
toml_ tables - Extracts TOML table headers from the input.
- is_
toml_ array_ table - Returns
truewhen a line is a TOML array-table header. - is_
toml_ table - Returns
truewhen a line is a TOML table header. - looks_
like_ toml - Returns
truewhen the input contains TOML-looking table or key-value lines. - quote_
toml_ string - Quotes a string as a TOML basic string.
- split_
toml_ key_ value - Splits a TOML key-value line on the first
=outside quotes. - unquote_
toml_ string - Unquotes a conservative TOML string literal.