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
56
57
58
59
#[derive(Clone, Debug, PartialEq)]
pub enum Integer {
/// Every non-negative integer is treated as u64, even if it fits in i64.
U64(u64),
/// Every negative integer is treated as i64.
I64(i64),
}
#[derive(Clone, Debug, PartialEq)]
pub enum Float {
F32(f32),
F64(f64),
}
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
/// Nil represents nil.
Nil,
/// Boolean represents true or false.
Boolean(bool),
/// Integer represents an integer.
Integer(Integer),
/// Float represents a floating point number.
Float(Float),
/// String extending Raw type represents a UTF-8 string.
String(String),
/// Binary extending Raw type represents a byte array.
Binary(Vec<u8>),
/// Array represents a sequence of objects.
Array(Vec<Value>),
/// Map represents key-value pairs of objects.
Map(Vec<(Value, Value)>),
/// Extended implements Extension interface: represents a tuple of type information and a byte
/// array where type information is an integer whose meaning is defined by applications.
Ext(i8, Vec<u8>),
}
#[derive(Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
/// Nil represents nil.
Nil,
/// Boolean represents true or false.
Boolean(bool),
/// Integer represents an integer.
Integer(Integer),
/// Float represents a floating point number.
Float(Float),
/// String extending Raw type represents a UTF-8 string.
String(&'a str),
/// Binary extending Raw type represents a byte array.
Binary(&'a [u8]),
/// Array represents a sequence of objects.
Array(&'a [ValueRef<'a>]),
/// Map represents key-value pairs of objects.
Map(&'a [(ValueRef<'a>, ValueRef<'a>)]),
/// Extended implements Extension interface: represents a tuple of type information and a byte
/// array where type information is an integer whose meaning is defined by applications.
Ext(i8, &'a [u8]),
}