mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-12-03 22:28:29 +00:00
aa043e8c00
Add a crate for deserializing command-line options given as key-values. This crate leverages serde to deserialize key-value argument strings (a commonly used pattern in crosvm) into configuration structures. This will allow us to remove a big part of the manual parsing currently done in `main.rs`, will provide consistent arguments to the `crosvm run` and `crosvm device` commands, and results in more precise error reporting. The use of serde will also allow us to similarly deserialize configuration structures from configuration files with very little extra code involved. As explained in the crate's documentation, its main entry point is a `from_key_values` function that allows a build a struct implementing serde's `Deserialize` trait from a key/values string. In order to integrate transparently with `argh`, there is also a `FromKeyValue` derive macro that automatically implements `FromArgValue` for structs deriving from it. BUG=b:218223240 BUG=b:217480043 TEST=cargo build TEST=cargo test -p serde_keyvalue Change-Id: Id6316e40150d5f08a05e6f04e39ecbc73d72dfa0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439669 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Anton Romanov <romanton@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
13 lines
178 B
TOML
13 lines
178 B
TOML
[package]
|
|
name = "serde_keyvalue_derive"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
|
|
[lib]
|
|
proc-macro = true
|
|
|
|
[dependencies]
|
|
argh = "0.1.7"
|
|
proc-macro2 = "1.0"
|
|
syn = "1.0"
|
|
quote = "1.0"
|