use reference to Jss inside PropertyMap

This commit is contained in:
Dietmar Maurer 2018-11-02 09:50:26 +01:00
parent 016aa6cbab
commit 8741bc2079
2 changed files with 11 additions and 12 deletions

View File

@ -1,6 +1,6 @@
use crate::static_map::StaticMap; use crate::static_map::StaticMap;
pub type PropertyMap<'a> = StaticMap<'a, &'a str, Jss<'a>>; pub type PropertyMap<'a> = StaticMap<'a, &'a str, &'a Jss<'a>>;
#[derive(Debug)] #[derive(Debug)]
pub struct JssBoolean<'a> { pub struct JssBoolean<'a> {
@ -50,7 +50,6 @@ pub enum Jss<'a> {
String(JssString<'a>), String(JssString<'a>),
Object(JssObject<'a>), Object(JssObject<'a>),
Array(JssArray<'a>), Array(JssArray<'a>),
Reference { reference: &'a Jss<'a> },
} }
pub static DEFAULTBOOL: JssBoolean = JssBoolean { pub static DEFAULTBOOL: JssBoolean = JssBoolean {

View File

@ -19,39 +19,39 @@ use hyper::rt::Future;
use hyper::service::service_fn_ok; use hyper::service::service_fn_ok;
static PARAMETERS1: PropertyMap = propertymap!{ static PARAMETERS1: PropertyMap = propertymap!{
force => Boolean!{ force => &Boolean!{
description => "Test for boolean options." description => "Test for boolean options."
}, },
text1 => ApiString!{ text1 => &ApiString!{
description => "A simple text string.", description => "A simple text string.",
min_length => Some(10), min_length => Some(10),
max_length => Some(30) max_length => Some(30)
}, },
count => Integer!{ count => &Integer!{
description => "A counter for everything.", description => "A counter for everything.",
minimum => Some(0), minimum => Some(0),
maximum => Some(10) maximum => Some(10)
}, },
myarray1 => Array!{ myarray1 => &Array!{
description => "Test Array of simple integers.", description => "Test Array of simple integers.",
items => &PVE_VMID items => &PVE_VMID
}, },
myarray2 => Jss::Array(JssArray { myarray2 => &Jss::Array(JssArray {
description: "Test Array of simple integers.", description: "Test Array of simple integers.",
optional: Some(false), optional: Some(false),
items: &Object!{description => "Empty Object."}, items: &Object!{description => "Empty Object."},
}), }),
myobject => Object!{ myobject => &Object!{
description => "TEST Object.", description => "TEST Object.",
properties => &propertymap!{ properties => &propertymap!{
vmid => Jss::Reference { reference: &PVE_VMID}, vmid => &PVE_VMID,
loop => Integer!{ loop => &Integer!{
description => "Totally useless thing.", description => "Totally useless thing.",
optional => Some(false) optional => Some(false)
} }
} }
}, },
emptyobject => Object!{description => "Empty Object."} emptyobject => &Object!{description => "Empty Object."}
}; };
@ -84,7 +84,7 @@ fn test_api_handler(param: Value) -> Result<Value, Error> {
static TEST_API_METHOD: ApiMethod = ApiMethod { static TEST_API_METHOD: ApiMethod = ApiMethod {
description: "This is a simple test.", description: "This is a simple test.",
properties: &propertymap!{ properties: &propertymap!{
force => Boolean!{ force => &Boolean!{
optional => Some(true), optional => Some(true),
description => "Test for boolean options." description => "Test for boolean options."
} }