neco-toml 0.1.0

zero dependency TOML subset parser
Documentation
  • Coverage
  • 8.33%
    1 out of 12 items documented1 out of 4 items with examples
  • Size
  • Source code size: 16.47 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 400.95 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • barineco/neco-parser
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • barineco

neco-toml

日本語

zero dependency TOML subset parser.

Features

  • Line-oriented key = value parsing
  • Empty values followed by - item lines converted to lists
  • Scalar parsing for null, bool, number, and string values
  • Field order preserved as Vec<(String, TomlValue)>
  • ParseError with line-oriented position and message

Usage

Parse

use neco_toml::{parse, TomlValue};

let value = parse("name = neco").unwrap();
assert!(matches!(value, TomlValue::Map(_)));

Read fields

use neco_toml::{parse, TomlValue};

let value = parse("name = neco").unwrap();
let TomlValue::Map(fields) = value else { panic!("map") };
assert!(fields.iter().any(|(key, value)| {
    key == "name" && matches!(value, TomlValue::String(text) if text == "neco")
}));

API

Item Description
parse(input: &str) -> Result<TomlValue, ParseError> Parses the supported TOML subset
TomlValue Null, Bool, Number(f64), String, List, or ordered Map
ParseError Reports line position and message

Format support

The supported subset covers flat configuration-shaped TOML with scalar values and simple arrays. It preserves duplicate keys in source order and does not implement the full TOML v1.0 grammar.

License

MIT