deser-toml
TOML 1.1 support for
deser. TOML is the format of choice
for configuration files that humans edit, and those humans make mistakes.
This crate is built to tell them exactly where: errors carry line, column
and (with deser-path) the path to the value, also for internally tagged
enums whose tag comes after the fields.
use ;
let config: Config = from_str.unwrap;
assert_eq!;
// sequences of maps are written as arrays of tables
assert_eq!;
// errors point at the problem
let err =
.unwrap_err;
assert_eq!;
- A from scratch implementation of TOML 1.1 which passes the toml-test suite.
- Date-times are passed through deser as the well-known
Datetimeextension type which falls back to strings. The date and time types ofjiff,chronoandtimecan be used directly with the respective features of deser. - Arbitrarily nested arrays and inline tables do not overflow the stack.
- The serializer writes maps as tables and sequences of maps as arrays of tables. The output is compatible with TOML 1.0.
- Source locations (see
deser::TrackLocations). from_readerandto_writerwork withstd::io, the configurations withdeser::ioand async runtimes (deser-tokio).
Conformance tests
The test data is vendored in tests/data and can be updated with
scripts/update-toml-test-data.sh. Run the suite with:
Pass parts of test names to only run some tests and to see the details of failures, including known ones:
Every valid test is also serialized again and has to roundtrip. Tests that
are expected to fail are listed in
tests/toml_test_suite_known_failures.txt. The run fails if a test fails
that is not listed there or if a listed test passes. After fixing tests,
update the list with:
DESER_TOML_BLESS=1