Skip to content

Commit 75345af

Browse files
intermediate state
1 parent acbab07 commit 75345af

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

amqp-lib/src/types/amqp_type.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ impl Encoded {
7070
}
7171
}
7272

73+
impl From<Encoded> for Vec<u8> {
74+
fn from(value: Encoded) -> Self {
75+
todo!()
76+
}
77+
}
78+
79+
impl From<Vec<Encoded>> for Vec<u8> {
80+
fn from(value: Vec<Encoded>) -> Self {
81+
todo!()
82+
}
83+
}
84+
7385
impl From<u8> for Encoded {
7486
fn from(value: u8) -> Self {
7587
Encoded::Empty(value)

amqp-lib/src/types/collection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ pub struct Map(IndexMap<AmqpType, AmqpType>);
1515
impl Encode for List {
1616
fn encode(&self) -> Encoded {
1717
let encoded: Vec<Encoded> = self.0.iter().map(|x| x.encode()).collect();
18+
let count = encoded.len();
1819
let byte_size = encoded.iter().fold(0, |acc, x| acc + x.data_len());
1920
match (encoded.len(), byte_size) {
2021
(0, _) => 0x45.into(),
21-
(len, size) if len <= 255 && size < 256 => 0xc0.into(),
22+
(len, size) if len <= 255 && size < 256 => Encoded::new_compound(0xc0, count, encoded.into()),
2223
(_, _) => 0xd0.into(),
2324
}
2425
}

0 commit comments

Comments
 (0)