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 5757 serde_json = " 1.0.0"
5858 uuid = { version = " 0.8" , features = [" serde" , " v4" ] }
5959 serde_yaml = " 0.8.23"
60+ enum_dispatch = " 0.3.8"
6061
6162 # OPTIONAL DEPENDENCIES
6263 # 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;
1717mod methods;
1818mod serde_convert;
1919mod value_type;
20+ mod declare;
2021
2122pub use {
2223 big_endian:: BigEndian ,
2324 cast:: { Cast , CastWithRules } ,
2425 convert:: { Convert , ConvertFrom } ,
2526 error:: ValueError ,
2627 value_type:: ValueType ,
28+ declare:: Value ,
2729} ;
2830
2931/// # Value
@@ -65,7 +67,9 @@ pub use {
6567///
6668/// Floats and Integers implicitly compare and convert.
6769/// (Feature: `implicit_float_conversion`)
68- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
70+
71+
72+ /*#[derive(Debug, Clone, Serialize, Deserialize)]
6973pub enum Value {
7074 Null,
7175
@@ -79,7 +83,7 @@ pub enum Value {
7983 Timestamp(i64),
8084
8185 Internal(i64),
82- }
86+ }*/
8387
8488impl Hash for Value {
8589 fn hash < H : Hasher > ( & self , state : & mut H ) {
@@ -93,7 +97,7 @@ impl Ord for Value {
9397 }
9498}
9599
96- impl From < bool > for Value {
100+ /* impl From<bool> for Value {
97101 fn from(from: bool) -> Value {
98102 Value::Bool(from)
99103 }
@@ -162,7 +166,7 @@ impl PartialOrd for Value {
162166 _ => None,
163167 }
164168 }
165- }
169+ }*/
166170
167171pub trait NullOrd {
168172 fn null_cmp ( & self , other : & Self ) -> Option < Ordering > ;
You can’t perform that action at this time.
0 commit comments