@@ -190,37 +190,37 @@ impl Encode for Uuid {
190
190
impl Encode for u32 {
191
191
fn encode ( & self ) -> Encoded {
192
192
match self {
193
- 0 => 0x43 . into ( ) ,
194
- x if x > & 0 && x <= & 255 => 0x52 . into ( ) ,
195
- _ => 0x70 . into ( ) ,
193
+ 0 => Encoded :: new ( 0x43 , None ) ,
194
+ x if x > & 0 && x <= & 255 => Encoded :: new ( 0x52 , Some ( x . to_be_bytes ( ) . to_vec ( ) ) ) ,
195
+ _ => Encoded :: new ( 0x70 , Some ( self . to_be_bytes ( ) . to_vec ( ) ) ) ,
196
196
}
197
197
}
198
198
}
199
199
200
200
impl Encode for u64 {
201
201
fn encode ( & self ) -> Encoded {
202
202
match self {
203
- 0 => 0x44 . into ( ) ,
204
- x if x > & & 0 && x <= & 255 => 0x53 . into ( ) ,
205
- _ => 0x80 . into ( ) ,
203
+ 0 => Encoded :: new ( 0x44 , None ) ,
204
+ x if x > & & 0 && x <= & 255 => Encoded :: new ( 0x53 , Some ( x . to_be_bytes ( ) . to_vec ( ) ) ) ,
205
+ _ => Encoded :: new ( 0x80 , Some ( self . to_be_bytes ( ) . to_vec ( ) ) )
206
206
}
207
207
}
208
208
}
209
209
210
210
impl Encode for i32 {
211
211
fn encode ( & self ) -> Encoded {
212
212
match self {
213
- x if x >= & -128 && x <= & 127 => 0x54 . into ( ) ,
214
- _ => 0x71 . into ( ) ,
213
+ x if x >= & -128 && x <= & 127 => Encoded :: new ( 0x54 , Some ( x . to_be_bytes ( ) . to_vec ( ) ) ) ,
214
+ _ => Encoded :: new ( 0x71 , Some ( self . to_be_bytes ( ) . to_vec ( ) ) )
215
215
}
216
216
}
217
217
}
218
218
219
219
impl Encode for i64 {
220
220
fn encode ( & self ) -> Encoded {
221
221
match self {
222
- x if x >= & -128 && x <= & 127 => 0x55 . into ( ) ,
223
- _ => 0x81 . into ( ) ,
222
+ x if x >= & -128 && x <= & 127 => Encoded :: new ( 0x55 , Some ( x . to_be_bytes ( ) . to_vec ( ) ) ) ,
223
+ _ => Encoded :: new ( 0x81 , Some ( self . to_be_bytes ( ) . to_vec ( ) ) )
224
224
}
225
225
}
226
226
}
@@ -231,16 +231,16 @@ impl Encode for String {
231
231
x if x >= 0 as usize && x <= 255 as usize => {
232
232
Encoded :: new ( 0xa1 , Some ( self . as_bytes ( ) . to_vec ( ) ) )
233
233
}
234
- _ => 0xb1 . into ( ) ,
234
+ _ => Encoded :: new ( 0xb1 , Some ( self . as_bytes ( ) . to_vec ( ) ) )
235
235
}
236
236
}
237
237
}
238
238
239
239
impl Encode for Symbol {
240
240
fn encode ( & self ) -> Encoded {
241
241
match self . 0 . len ( ) {
242
- x if x <= 255 => 0xa3 . into ( ) ,
243
- _ => 0xb1 . into ( ) ,
242
+ x if x <= 255 => Encoded :: new ( 0xa3 , Some ( self . 0 . as_bytes ( ) . to_vec ( ) ) ) ,
243
+ _ => Encoded :: new ( 0xb1 , Some ( self . 0 . as_bytes ( ) . to_vec ( ) ) ) ,
244
244
}
245
245
}
246
246
}
0 commit comments