deser-ini
INI files (and git's config files) for deser.
INI has no specification, every implementation reads it a little
differently. The default dialect is based on a survey of INI files on GitHub
and reads what is common today: ; and # comments (also after values),
= and : delimiters, values continued on indented lines (like Python's
configparser), quoted values (like PHP, MySQL and Windows) and keys without
values. Presets read the files of Python's configparser and git's config
files.
use ;
let config: Config = from_str.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
What works:
- Sections, keys before the first section, sections that repeat (they are
merged) and keys that repeat (collected by
Vec<T>fields, otherwise the last value is used). - Comments after values,
:delimiters, continuation lines, quotes, keys without values and lowercased names can be configured.DeserializerConfig::python()readssetup.cfg,tox.iniand the like,DeserializerConfig::git()reads.gitconfigand.gitmoduleslike git (subsections, escapes and git's quoting). - Everything is text that is parsed by the type it ends up in, also after
buffering (flattened structs, internally tagged and untagged enums).
Booleans accept
yes,onand1, empty values areNonefor optionals. - Errors point at the line and column (and with
deser-pathat the path of the value). - Serializing writes the keys before the first section, quotes values only where needed and writes values with line breaks as continuation lines.
Tested against inih, Python's configparser and git with a corpus of the
test inputs of INI parsers and real world files (see
tests/data).
License and Links
- Issue Tracker
- Documentation
- License: Apache-2.0