proxmox-api: rename ApiStringFormat::Complex into ApiStringFormat::PropertyString

This commit is contained in:
Dietmar Maurer 2019-11-24 09:51:45 +01:00
parent 38abbed608
commit e4d44ae7a3

View File

@ -236,7 +236,7 @@ impl StringSchema {
bail!("value '{}' is not defined in the enumeration.", value); bail!("value '{}' is not defined in the enumeration.", value);
} }
} }
ApiStringFormat::Complex(subschema) => { ApiStringFormat::PropertyString(subschema) => {
parse_property_string(value, subschema)?; parse_property_string(value, subschema)?;
} }
ApiStringFormat::VerifyFn(verify_fn) => { ApiStringFormat::VerifyFn(verify_fn) => {
@ -420,7 +420,7 @@ pub enum Schema {
/// .schema(); /// .schema();
/// ///
/// const SCHEMA: Schema = StringSchema::new("A list on integers, comma separated.") /// const SCHEMA: Schema = StringSchema::new("A list on integers, comma separated.")
/// .format(&ApiStringFormat::Complex(&LIST_SCHEMA)) /// .format(&ApiStringFormat::PropertyString(&LIST_SCHEMA))
/// .schema(); /// .schema();
/// ///
/// let res = parse_simple_value("", &SCHEMA); /// let res = parse_simple_value("", &SCHEMA);
@ -446,7 +446,7 @@ pub enum ApiStringFormat {
/// ///
/// Objects are parsed as comma separated `key=value` pairs, i.e: /// Objects are parsed as comma separated `key=value` pairs, i.e:
/// `"prop1=2,prop2=test"` /// `"prop1=2,prop2=test"`
Complex(&'static Schema), PropertyString(&'static Schema),
/// Use a verification function. /// Use a verification function.
VerifyFn(fn(&str) -> Result<(), Error>), VerifyFn(fn(&str) -> Result<(), Error>),
} }
@ -457,7 +457,7 @@ impl std::fmt::Debug for ApiStringFormat {
ApiStringFormat::VerifyFn(fnptr) => write!(f, "VerifyFn({:p}", fnptr), ApiStringFormat::VerifyFn(fnptr) => write!(f, "VerifyFn({:p}", fnptr),
ApiStringFormat::Enum(strvec) => write!(f, "Enum({:?}", strvec), ApiStringFormat::Enum(strvec) => write!(f, "Enum({:?}", strvec),
ApiStringFormat::Pattern(regex) => write!(f, "Pattern({:?}", regex), ApiStringFormat::Pattern(regex) => write!(f, "Pattern({:?}", regex),
ApiStringFormat::Complex(schema) => write!(f, "Complex({:?}", schema), ApiStringFormat::PropertyString(schema) => write!(f, "PropertyString({:?}", schema),
} }
} }
} }
@ -474,7 +474,7 @@ pub fn parse_boolean(value_str: &str) -> Result<bool, Error> {
} }
} }
/// Parse a complex property string (`ApiStringFormat::Complex`) /// Parse a complex property string (`ApiStringFormat::PropertyString`)
pub fn parse_property_string(value_str: &str, schema: &Schema) -> Result<Value, Error> { pub fn parse_property_string(value_str: &str, schema: &Schema) -> Result<Value, Error> {
match schema { match schema {
@ -1032,7 +1032,7 @@ fn test_verify_complex_object() {
"net0", "net0",
false, false,
&StringSchema::new("First Network device.") &StringSchema::new("First Network device.")
.format(&ApiStringFormat::Complex(&PARAM_SCHEMA)) .format(&ApiStringFormat::PropertyString(&PARAM_SCHEMA))
.schema(), .schema(),
)], )],
); );
@ -1068,7 +1068,7 @@ fn test_verify_complex_array() {
"list", "list",
false, false,
&StringSchema::new("A list on integers, comma separated.") &StringSchema::new("A list on integers, comma separated.")
.format(&ApiStringFormat::Complex(&PARAM_SCHEMA)) .format(&ApiStringFormat::PropertyString(&PARAM_SCHEMA))
.schema(), .schema(),
)], )],
); );
@ -1102,7 +1102,7 @@ fn test_verify_complex_array() {
"list", "list",
false, false,
&StringSchema::new("A list on integers, comma separated.") &StringSchema::new("A list on integers, comma separated.")
.format(&ApiStringFormat::Complex(&PARAM_SCHEMA)) .format(&ApiStringFormat::PropertyString(&PARAM_SCHEMA))
.schema(), .schema(),
)], )],
); );