1use std::fmt;
5
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum Value
10{
11 #[serde(rename="i64")] Integer(i64),
13
14 #[serde(rename="f64")] Float(f64),
16
17 #[serde(rename="str")] String(String),
19
20 #[serde(rename="bool")] Boolean(bool),
22
23}
24
25
26impl fmt::Display for Value
27{
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
29 {
30 match self
31 {
32 Value::Integer(v) => v.fmt(f),
33 Value::Float(v) => v.fmt(f),
34 Value::String(v) => v.fmt(f),
35 Value::Boolean(v) => v.fmt(f),
36 }
37 }
38}
39
40
41impl From<i64> for Value { fn from(other: i64) -> Self { Value::Integer(other) }}
42impl From<f64> for Value { fn from(other: f64) -> Self { Value::Float(other) }}
43impl From<String> for Value { fn from(other: String) -> Self { Value::String(other) }}
44impl From<bool> for Value { fn from(other: bool) -> Self { Value::Boolean(other) }}