crosvm/serde_keyvalue
Alexandre Courbot 68d895fdf6 serde_keyvalue: fix parsing of flattened structs
Outer structs that contain a flattened element are not parsed with
`deserialize_struct`, which meant the `top_struct_parsed` remained
false. Fix that by also flipping it in `deserialize_map`, which is used
for the flattened top-level structs.

BUG=b:217480278
TEST=cargo test -p serde_keyvalue

Change-Id: I2288361d63de21de7f55ee5ffbd130ee562d2df2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4596441
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-06-09 02:59:31 +00:00
..
serde_keyvalue_derive Update all copyright headers to match new style 2022-09-13 18:41:29 +00:00
src serde_keyvalue: fix parsing of flattened structs 2023-06-09 02:59:31 +00:00
Cargo.toml Fix remaining Chrome/Chromium OS instances 2023-01-03 22:14:30 +00:00
README.md add serde_keyvalue crate 2022-03-24 01:33:21 +00:00

Serde deserializer from key=value strings

A lightweight serde deserializer for strings containing key-value pairs separated by commas, as commonly found in command-line parameters.

Say your program takes a command-line option of the form:

--foo type=bar,active,nb_threads=8

This crate provides a from_key_values function that deserializes these key-values into a configuration structure. Since it uses serde, the same configuration structure can also be created from any other supported source (such as a TOML or YAML configuration file) that uses the same keys.

Integration with the argh command-line parser is also provided via the argh_derive feature.

See the inline documentation for examples and more details.