From 4a4cdf7d148be0a2a756f323d27c0ee5b7976438 Mon Sep 17 00:00:00 2001 From: troido Date: Fri, 14 Feb 2020 14:36:32 +0100 Subject: extract the state to save --- src/parameter.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/parameter.rs') 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)] -- cgit