1
1
use bigdecimal:: BigDecimal ;
2
+ use indexmap:: IndexMap ;
2
3
3
4
use crate :: error:: AppError ;
4
5
trait Encode {
@@ -10,15 +11,17 @@ trait Decode<'a>: From<&'a [u8]> + Encode {}
10
11
pub struct Timestamp ( u64 ) ;
11
12
pub struct Binary ( Vec < u8 > ) ;
12
13
pub struct Symbol ( String ) ;
13
- pub struct List ( ) ;
14
- pub struct Map ( ) ;
15
- pub struct Array ( ) ;
16
14
pub struct Uuid ( uuid:: Uuid ) ;
17
15
pub struct Described ( ) ;
18
16
pub struct Constructor ( u8 ) ;
19
17
pub struct Decimal32 ( BigDecimal ) ;
20
18
pub struct Decimal64 ( BigDecimal ) ;
21
19
pub struct Decimal128 ( BigDecimal ) ;
20
+ pub struct List ( Vec < AmqpType > ) ;
21
+ pub struct Array ( Vec < AmqpType > ) ;
22
+ pub struct Map ( IndexMap < AmqpType , AmqpType > ) ;
23
+
24
+
22
25
pub enum AmqpType {
23
26
Null ,
24
27
Boolean ( bool ) ,
@@ -41,9 +44,9 @@ pub enum AmqpType {
41
44
Binary ( Binary ) ,
42
45
String ( String ) ,
43
46
Symbol ( Symbol ) ,
44
- // List(List),
45
- // Map(Map),
46
- // Array(Array<T> ),
47
+ List ( List ) ,
48
+ Map ( Map ) ,
49
+ Array ( Array ) ,
47
50
}
48
51
49
52
impl Encode for AmqpType {
@@ -70,9 +73,9 @@ impl Encode for AmqpType {
70
73
Self :: Binary ( val) => val. constructor ( ) ,
71
74
Self :: String ( val) => val. constructor ( ) ,
72
75
Self :: Symbol ( val) => val. constructor ( ) ,
73
- // Self::List(val) => val.constructor(),
74
- // Self::Map(val) => val.constructor(),
75
- // Self::Array(val) => val.constructor(),
76
+ Self :: List ( val) => val. constructor ( ) ,
77
+ Self :: Map ( val) => val. constructor ( ) ,
78
+ Self :: Array ( val) => val. constructor ( ) ,
76
79
}
77
80
}
78
81
@@ -99,6 +102,9 @@ impl Encode for AmqpType {
99
102
Self :: Binary ( val) => val. encode ( ) ,
100
103
Self :: String ( val) => val. encode ( ) ,
101
104
Self :: Symbol ( val) => val. encode ( ) ,
105
+ Self :: List ( val) => val. encode ( ) ,
106
+ Self :: Map ( val) => val. encode ( ) ,
107
+ Self :: Array ( val) => val. encode ( ) ,
102
108
}
103
109
}
104
110
}
0 commit comments