mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +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>
18 lines
No EOL
433 B
TOML
18 lines
No EOL
433 B
TOML
[package]
|
|
name = "serde_keyvalue"
|
|
version = "0.1.0"
|
|
authors = ["The Chromium OS Authors"]
|
|
edition = "2021"
|
|
|
|
[features]
|
|
argh_derive = ["argh", "serde_keyvalue_derive"]
|
|
|
|
[dependencies]
|
|
argh = { version = "0.1.7", optional = true }
|
|
serde_keyvalue_derive = { path = "serde_keyvalue_derive", optional = true }
|
|
serde = "1"
|
|
thiserror = { version = "1.0.20" }
|
|
remain = "*"
|
|
|
|
[dev-dependencies]
|
|
serde = { version = "1", features = ["derive"] } |