mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
b53a156fbc
This adds support for parsing hex `m=0x1234abcd` octal `0o755` and binary `m=0o1100` values according the their prefix. Negative numbers can also be specified by adding a `-` after the prefix. Note that negative values like `m=-0x1234` don't work, largely as an artifact of the way the Num trait works. This could probably be fixed, but given hex, octal, and binary numbers tend to be used in unsigned situations most of the time this shouldn't be an issue. The main motivation for this is the debugcon serial device, which accepts an argument which is an x86 IO port. These are much more naturally described in hex. BUG=b:233610263 Change-Id: Ic68bacd772de6aebfaad0de7b8aa6faf5d4c1555 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671595 Commit-Queue: Mike Gerow <gerow@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> |
||
---|---|---|
.. | ||
serde_keyvalue_derive | ||
src | ||
Cargo.toml | ||
README.md |
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.