diff options
| author | troido <troido@protonmail.com> | 2020-02-14 14:36:32 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-14 14:36:32 +0100 |
| commit | 4a4cdf7d148be0a2a756f323d27c0ee5b7976438 (patch) | |
| tree | 7add0a0d735f93cb1fce6ae4f0c476a0d550a3ee /src/parameter.rs | |
| parent | 7821febc8ee4c89ca1825054e0baf39eea3a0380 (diff) | |
extract the state to save
Diffstat (limited to 'src/parameter.rs')
| -rw-r--r-- | src/parameter.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/parameter.rs b/src/parameter.rs index 56f1cbf..cca0681 100644 --- a/src/parameter.rs +++ b/src/parameter.rs @@ -1,5 +1,5 @@ -use serde_json::Value; +use serde_json::{Value, json}; use crate::template::Template; #[derive(Debug, PartialEq, Clone)] @@ -52,6 +52,15 @@ impl Parameter { }; Self::from_typed_json(typ, val) } + + pub fn to_json(&self) -> Value { + match self { + Self::String(s) => json!(s), + Self::Int(i) => json!(i), + Self::Float(f) => json!(f), + Self::Template(t) => t.to_json() + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
