1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::collections::HashMap;
use std::fmt::Debug;
use crate::value::bytes::Bytes;
pub mod bytes;
#[derive(Debug, Clone, PartialEq)]
pub enum Value<S> {
Null,
Boolean(bool),
Integer(i64),
Float(f64),
Bytes(Bytes),
String(String),
List(Vec<Value<S>>),
Dictionary(HashMap<String, Value<S>>),
Structure(S)
}
impl<S> From<i64> for Value<S> {
fn from(i: i64) -> Self {
Value::Integer(i)
}
}
impl<S> From<bool> for Value<S> {
fn from(b: bool) -> Self {
Value::Boolean(b)
}
}
impl<S> From<f64> for Value<S> {
fn from(f: f64) -> Self {
Value::Float(f)
}
}
impl<S> From<&str> for Value<S> {
fn from(s: &str) -> Self {
Value::String(String::from(s))
}
}
impl<S> From<String> for Value<S> {
fn from(s: String) -> Self {
Value::String(s)
}
}