Skip to main content

Crate use_toml

Crate use_toml 

Source
Expand description

§use-toml

Practical TOML utility primitives for lightweight table, key, and string handling.

Warning: versions below 0.3.0 are 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§

TomlKeyValue
A discovered TOML key-value pair.
TomlTable
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 true when a line is a TOML array-table header.
is_toml_table
Returns true when a line is a TOML table header.
looks_like_toml
Returns true when 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.