File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 57
57
serde_json = " 1.0.0"
58
58
uuid = { version = " 0.8" , features = [" serde" , " v4" ] }
59
59
serde_yaml = " 0.8.23"
60
+ enum_dispatch = " 0.3.8"
60
61
61
62
# OPTIONAL DEPENDENCIES
62
63
# Storages
Original file line number Diff line number Diff line change
1
+ use {
2
+ serde:: { Deserialize , Serialize } ,
3
+ std:: fmt:: Debug ,
4
+ enum_dispatch:: enum_dispatch,
5
+ } ;
6
+
7
+ #[ enum_dispatch]
8
+ pub trait Valued {
9
+
10
+ }
11
+
12
+ macro_rules! value_types {
13
+ ( $( $representation: ident: $type: ty) ,* ) => {
14
+ $( impl Valued for $type { } ) *
15
+
16
+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
17
+ #[ enum_dispatch( Valued ) ]
18
+ pub enum Value {
19
+ Null ,
20
+ $( $representation( $type) ) ,*
21
+ }
22
+ }
23
+ }
24
+
25
+ /*value_types!(
26
+ Boolean: bool,
27
+ UInteger: u64,
28
+ Integer: i64,
29
+ Float: f64,
30
+ Text: String,
31
+ );*/
32
+ value_types ! (
33
+ Bool : bool ,
34
+ U64 : u64 ,
35
+ I64 : i64 ,
36
+ F64 : f64 ,
37
+ Str : String
38
+ ) ;
Original file line number Diff line number Diff line change @@ -17,13 +17,15 @@ mod literal;
17
17
mod methods;
18
18
mod serde_convert;
19
19
mod value_type;
20
+ mod declare;
20
21
21
22
pub use {
22
23
big_endian:: BigEndian ,
23
24
cast:: { Cast , CastWithRules } ,
24
25
convert:: { Convert , ConvertFrom } ,
25
26
error:: ValueError ,
26
27
value_type:: ValueType ,
28
+ declare:: Value ,
27
29
} ;
28
30
29
31
/// # Value
@@ -65,7 +67,9 @@ pub use {
65
67
///
66
68
/// Floats and Integers implicitly compare and convert.
67
69
/// (Feature: `implicit_float_conversion`)
68
- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
70
+
71
+
72
+ /*#[derive(Debug, Clone, Serialize, Deserialize)]
69
73
pub enum Value {
70
74
Null,
71
75
@@ -79,7 +83,7 @@ pub enum Value {
79
83
Timestamp(i64),
80
84
81
85
Internal(i64),
82
- }
86
+ }*/
83
87
84
88
impl Hash for Value {
85
89
fn hash < H : Hasher > ( & self , state : & mut H ) {
@@ -93,7 +97,7 @@ impl Ord for Value {
93
97
}
94
98
}
95
99
96
- impl From < bool > for Value {
100
+ /* impl From<bool> for Value {
97
101
fn from(from: bool) -> Value {
98
102
Value::Bool(from)
99
103
}
@@ -162,7 +166,7 @@ impl PartialOrd for Value {
162
166
_ => None,
163
167
}
164
168
}
165
- }
169
+ }*/
166
170
167
171
pub trait NullOrd {
168
172
fn null_cmp ( & self , other : & Self ) -> Option < Ordering > ;
You can’t perform that action at this time.
0 commit comments