Skip to content

Commit c29fd89

Browse files
added types for collections
1 parent 2c41ceb commit c29fd89

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

Cargo.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amqp-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async-trait = "0.1.73"
1515
bigdecimal = "0.4.1"
1616
byteorder = "1.4.3"
1717
bytes = "1.4.0"
18+
indexmap = "2.0.0"
1819
thiserror = "1.0.47"
1920
tokio = {version = "1", features=["full"]}
2021
tracing = "0.1.37"

amqp-lib/src/types.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use bigdecimal::BigDecimal;
2+
use indexmap::IndexMap;
23

34
use crate::error::AppError;
45
trait Encode {
@@ -10,15 +11,17 @@ trait Decode<'a>: From<&'a [u8]> + Encode {}
1011
pub struct Timestamp(u64);
1112
pub struct Binary(Vec<u8>);
1213
pub struct Symbol(String);
13-
pub struct List();
14-
pub struct Map();
15-
pub struct Array();
1614
pub struct Uuid(uuid::Uuid);
1715
pub struct Described();
1816
pub struct Constructor(u8);
1917
pub struct Decimal32(BigDecimal);
2018
pub struct Decimal64(BigDecimal);
2119
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+
2225
pub enum AmqpType {
2326
Null,
2427
Boolean(bool),
@@ -41,9 +44,9 @@ pub enum AmqpType {
4144
Binary(Binary),
4245
String(String),
4346
Symbol(Symbol),
44-
// List(List),
45-
// Map(Map),
46-
// Array(Array<T>),
47+
List(List),
48+
Map(Map),
49+
Array(Array),
4750
}
4851

4952
impl Encode for AmqpType {
@@ -70,9 +73,9 @@ impl Encode for AmqpType {
7073
Self::Binary(val) => val.constructor(),
7174
Self::String(val) => val.constructor(),
7275
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(),
7679
}
7780
}
7881

@@ -99,6 +102,9 @@ impl Encode for AmqpType {
99102
Self::Binary(val) => val.encode(),
100103
Self::String(val) => val.encode(),
101104
Self::Symbol(val) => val.encode(),
105+
Self::List(val) => val.encode(),
106+
Self::Map(val) => val.encode(),
107+
Self::Array(val) => val.encode(),
102108
}
103109
}
104110
}

0 commit comments

Comments
 (0)