crosvm/serde_keyvalue
Alexandre Courbot f8458abf49 serde_keyvalue: allow structs with default values to be left unspecified
Allow optional structs which members all have default values to have
their values omitted. This is convenient when we want to specify a flag
that can take optional extra arguments.

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

Change-Id: If2920834f3221146439fc6b8ac54cd9cb215cb9e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4596440
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-06-09 02:58:41 +00:00
..
serde_keyvalue_derive Update all copyright headers to match new style 2022-09-13 18:41:29 +00:00
src serde_keyvalue: allow structs with default values to be left unspecified 2023-06-09 02:58:41 +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.