@@ -9,8 +9,10 @@ pub enum Value<'a> {
9
9
I64 ( i64 ) ,
10
10
F32 ( f32 ) ,
11
11
F64 ( f64 ) ,
12
- Char ( & ' a str ) ,
12
+ Timestamp ( i64 ) ,
13
+ String ( & ' a str ) ,
13
14
Binary ( & ' a [ u8 ] ) ,
15
+ Bool ( bool ) ,
14
16
}
15
17
16
18
impl Display for Value < ' _ > {
@@ -23,8 +25,10 @@ impl Display for Value<'_> {
23
25
Value :: I64 ( v) => write ! ( f, "{}" , v) ,
24
26
Value :: F32 ( v) => write ! ( f, "{}" , v) ,
25
27
Value :: F64 ( v) => write ! ( f, "{}" , v) ,
26
- Value :: Char ( v) => write ! ( f, "{}" , v) ,
28
+ Value :: Timestamp ( v) => write ! ( f, "{}" , v) ,
29
+ Value :: String ( v) => write ! ( f, "{}" , v) ,
27
30
Value :: Binary ( v) => write ! ( f, "{:?}" , v) ,
31
+ Value :: Bool ( v) => write ! ( f, "{}" , v) ,
28
32
}
29
33
}
30
34
}
@@ -45,14 +49,19 @@ impl<'a> Value<'a> {
45
49
DataType :: BigInt => Value :: I64 ( xdb_column_int64 ( meta, row, col) ) ,
46
50
DataType :: Float => Value :: F32 ( xdb_column_float ( meta, row, col) ) ,
47
51
DataType :: Double => Value :: F64 ( xdb_column_double ( meta, row, col) ) ,
52
+ DataType :: Timestamp => Value :: Timestamp ( xdb_column_int64 ( meta, row, col) ) ,
48
53
DataType :: Char | DataType :: VChar => {
49
- let s = CStr :: from_ptr ( xdb_column_str ( meta, row, col) ) ;
50
- Value :: Char ( s. to_str ( ) . unwrap ( ) )
54
+ let ptr = xdb_column_str ( meta, row, col) ;
55
+ if ptr. is_null ( ) {
56
+ return Value :: Null ;
57
+ }
58
+ Value :: String ( CStr :: from_ptr ( ptr) . to_str ( ) . unwrap ( ) )
51
59
}
52
60
DataType :: Binary | DataType :: VBinary => {
53
61
// xdb_column_blob(meta, row, col, pLen);
54
62
todo ! ( )
55
63
}
64
+ DataType :: Bool => Value :: Bool ( xdb_column_int ( meta, row, col) == 1 ) ,
56
65
_ => unimplemented ! ( ) ,
57
66
}
58
67
}
0 commit comments