crosvm/serde_keyvalue
Alexandre Courbot 171752d9ee serde_keyvalue: fix parsing of quoted strings in a sequence
Parsing a quoted string as the last element of a sequence would fail
since ']' was not recognized as a separator. Fix this and factorize the
code recognizing separators into a single function to prevent this kind
of issue from happening again in the future.

BUG=None
TEST=cargo test -p serde_keyvalue

Change-Id: I1367da843787c40fb6c15a615d7cd036bddd1381
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4054812
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-11-29 00:24:44 +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 quoted strings in a sequence 2022-11-29 00:24:44 +00:00
Cargo.toml Adding missing # provided by ebuild to Cargo.tomls 2022-10-14 16:42:38 +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.