Skip to main content

Module toml

Module toml 

Source
Expand description

Simple TOML parser for kernel boot configuration Minimal TOML subset parser for kernel boot configuration.

Zero-copy design: keys, section names and unescaped string values borrow directly from the source buffer (Cow::Borrowed); only values requiring escape-sequence expansion allocate. Entries are stored in one flat, sorted Vec (binary-search lookups) instead of nested maps : the config is parsed once at boot and read-only afterwards.

§Lifetime contract

[TomlConfig<'a>] borrows the input buffer: the caller must keep the TOML text alive for as long as the config is used. This is natural for boot configs read from persistent regions (initfs / mapped file).

§Supported subset

  • [section] headers (no nested tables, non-empty names)
  • key = value inside a section (keys before any header are rejected)
  • Value types: integers (decimal + 0x hex), booleans, basic strings
  • # comments, full-line or trailing, respecting quoted strings
  • Basic-string escapes: \n \t \r \" \\

Not supported by design: floats, arrays, inline tables, multi-line strings, dotted keys, duplicate keys (rejected at parse time).

Structs§

TomlConfig
Parsed TOML configuration: flat (section, key, value) triples kept sorted for O(log n) binary-search lookups with minimal memory overhead.

Enums§

ConfigValue
A single configuration value.

Functions§

parse_toml
Parse a TOML-subset document. The returned config borrows data.
strip_comment 🔒
Strip a trailing # comment, ignoring # inside quoted strings.
unescape_cow 🔒
Expand basic-string escapes, borrowing when there is nothing to expand.