]> git.proxmox.com Git - proxmox.git/commit
add the ParseCli trait
authorWolfgang Bumiller <wry.git@bumiller.com>
Sat, 15 Jun 2019 09:41:14 +0000 (11:41 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 17 Jun 2019 10:31:29 +0000 (12:31 +0200)
commit691af5cadec534630d159d20174b186677a77313
treef540d6a0958087847a73995be96d98d61ab43103
parentdc3b88f50c552e9e87cfaabff09bd12fa309ee91
add the ParseCli trait

In order to get parameters from the command line into the
API we need to get them into a json value, so that we can
pass it down the handler which deserializes them into their
real type and runs verifications.
For this we need to define how the type is going to be
converted into a json Value. We cannot simply use
Deserialize as that would for instance require quotes
around strings. So instead, we have a ParseCli trait, which
is a nop (direct serde_json::Value::String()) for string
types, and uses .parse() (the std::str::FromStr trait) for
everything else.

Currently this uses a `default fn` as an example of the
specialization feature, but I'll probably remove this and
use yet another mass-impl macro since there isn't much
activity on that feature's issue tracker. (The issue itself
seems to be outdated ...

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
proxmox-api-macro/src/api_macro.rs
proxmox-api/src/api_type.rs
proxmox-api/src/cli.rs
proxmox-api/src/lib.rs
proxmox-api/src/router.rs
proxmox-api/tests/router.rs