diff --git a/proxmox-api/src/api_type.rs b/proxmox-api/src/api_type.rs index 6ab62055..fe3fb057 100644 --- a/proxmox-api/src/api_type.rs +++ b/proxmox-api/src/api_type.rs @@ -1,5 +1,7 @@ //! This contains traits used to implement methods to be added to the `Router`. +use std::collections::HashSet; + use failure::{bail, Error}; use http::Response; use serde_json::{json, Value}; @@ -313,6 +315,7 @@ unconstrained_api_type! {String, &str} unconstrained_api_type! {bool} unconstrained_api_type! {isize, usize, i64, u64, i32, u32, i16, u16, i8, u8, f64, f32} unconstrained_api_type! {Vec} +unconstrained_api_type! {HashSet} // Raw return types are also okay: impl ApiType for Response { diff --git a/proxmox-api/src/cli.rs b/proxmox-api/src/cli.rs index f1bde19c..b4395531 100644 --- a/proxmox-api/src/cli.rs +++ b/proxmox-api/src/cli.rs @@ -1,6 +1,6 @@ //! Provides Command Line Interface to API methods -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::str::FromStr; use bytes::Bytes; @@ -382,3 +382,16 @@ impl ParseCli for String { )) } } + +impl ParseCli for HashSet { + fn parse_cli(name: &str, value: Option<&str>) -> Result { + Ok(serde_json::Value::Array(value + .ok_or_else(|| format_err!("missing value for parameter '{}'", name))? + .split(';') + .fold(Vec::new(), |mut list, entry| { + list.push(serde_json::Value::String(entry.trim().to_string())); + list + }) + )) + } +}