crosvm/serde_keyvalue
Alexandre Courbot 8b75feb12f serde_keyvalue: more natural signed number parsing
Support parsing negative numbers with a specified radix as e.g.
`-0xff00` instead of `0x-ff00`.  This is a potentially breaking change
but I don't believe anyone made use of the former syntax anyway.

The new number parser has the nice side-effect of removing some extra
code, and also signaling parsing errors more accurately, so that's an
added bonus. On the other hand we lose the distinction between "invalid
number" and "expected number", but that distinction was dubious anyway
so losing it is for the better IMHO.

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

Change-Id: I6b2943ecd0df92071afe0682b339dcf5b59e2826
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3853315
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
2022-08-27 03:27:48 +00:00
..
serde_keyvalue_derive Reformat imports 2022-07-28 00:15:50 +00:00
src serde_keyvalue: more natural signed number parsing 2022-08-27 03:27:48 +00:00
Cargo.toml serde_keyvalue: use nom crate for parsing 2022-08-24 00:37:59 +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.