summaryrefslogtreecommitdiff
path: root/src/parameter.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-22 23:41:51 +0100
committertroido <troido@protonmail.com>2020-02-22 23:41:51 +0100
commit522aad7889cd62e96af7c420789507ccbf5b7aaa (patch)
treebfb3c21d627552bcda6f2743854cee920722fd3b /src/parameter.rs
parentf4331041e5d906f95063f317852f32f19e6cdf9c (diff)
it is now possible to use items
Diffstat (limited to 'src/parameter.rs')
-rw-r--r--src/parameter.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/parameter.rs b/src/parameter.rs
index e82915b..65dd4d0 100644
--- a/src/parameter.rs
+++ b/src/parameter.rs
@@ -1,6 +1,7 @@
use serde_json::{Value, json};
use crate::template::Template;
+use crate::components::item::ItemAction;
#[derive(Debug, PartialEq, Clone)]
pub enum Parameter {
@@ -8,7 +9,8 @@ pub enum Parameter {
Int(i64),
// Pos(Pos),
Float(f64),
- Template(Template)
+ Template(Template),
+ Action(ItemAction)
}
impl Parameter {
@@ -23,7 +25,8 @@ impl Parameter {
ParameterType::String => Some(Self::String(val.as_str()?.to_string())),
ParameterType::Int => Some(Self::Int(val.as_i64()?)),
ParameterType::Float => Some(Self::Float(val.as_f64()?)),
- ParameterType::Template => Some(Self::Template(Template::from_json(val).ok()?))
+ ParameterType::Template => Some(Self::Template(Template::from_json(val).ok()?)),
+ ParameterType::Action => Some(Self::Action(ItemAction::from_json(val)?))
}
}
@@ -32,7 +35,8 @@ impl Parameter {
Self::String(_) => ParameterType::String,
Self::Int(_) => ParameterType::Int,
Self::Float(_) => ParameterType::Float,
- Self::Template(_) => ParameterType::Template
+ Self::Template(_) => ParameterType::Template,
+ Self::Action(_) => ParameterType::Action
}
}
@@ -58,7 +62,8 @@ impl Parameter {
Self::String(s) => json!(s),
Self::Int(i) => json!(i),
Self::Float(f) => json!(f),
- Self::Template(t) => t.to_json()
+ Self::Template(t) => t.to_json(),
+ Self::Action(a) => a.to_json()
}
}
}
@@ -68,7 +73,8 @@ pub enum ParameterType {
String,
Int,
Float,
- Template
+ Template,
+ Action
}
impl ParameterType {
@@ -79,6 +85,7 @@ impl ParameterType {
"int" => Some(Self::Int),
"float" => Some(Self::Float),
"template" => Some(Self::Template),
+ "action" => Some(Self::Action),
_ => None
}
}