@@ -11,7 +11,7 @@ use crate::error::AmqpParseError;
11
11
use crate :: framing:: { self , AmqpFrame , SaslFrame , HEADER_LEN } ;
12
12
use crate :: protocol:: { self , CompoundHeader } ;
13
13
use crate :: types:: {
14
- Descriptor , List , Multiple , Str , Symbol , Variant , VariantMap , VecStringMap , VecSymbolMap ,
14
+ Array , Descriptor , List , Multiple , Str , Symbol , Variant , VariantMap , VecStringMap , VecSymbolMap ,
15
15
} ;
16
16
use crate :: HashMap ;
17
17
@@ -376,37 +376,31 @@ impl DecodeFormatted for Variant {
376
376
DateTime :: < Utc > :: decode_with_format ( input, fmt) . map ( Variant :: Timestamp )
377
377
}
378
378
codec:: FORMATCODE_UUID => Uuid :: decode_with_format ( input, fmt) . map ( Variant :: Uuid ) ,
379
- codec:: FORMATCODE_BINARY8 => Bytes :: decode_with_format ( input, fmt) . map ( Variant :: Binary ) ,
380
- codec:: FORMATCODE_BINARY32 => {
379
+ codec:: FORMATCODE_BINARY8 | codec:: FORMATCODE_BINARY32 => {
381
380
Bytes :: decode_with_format ( input, fmt) . map ( Variant :: Binary )
382
381
}
383
- codec:: FORMATCODE_STRING8 => {
382
+ codec:: FORMATCODE_STRING8 | codec :: FORMATCODE_STRING32 => {
384
383
ByteString :: decode_with_format ( input, fmt) . map ( |o| Variant :: String ( o. into ( ) ) )
385
384
}
386
- codec:: FORMATCODE_STRING32 => {
387
- ByteString :: decode_with_format ( input, fmt) . map ( |o| Variant :: String ( o. into ( ) ) )
388
- }
389
- codec:: FORMATCODE_SYMBOL8 => {
390
- Symbol :: decode_with_format ( input, fmt) . map ( Variant :: Symbol )
391
- }
392
- codec:: FORMATCODE_SYMBOL32 => {
385
+ codec:: FORMATCODE_SYMBOL8 | codec:: FORMATCODE_SYMBOL32 => {
393
386
Symbol :: decode_with_format ( input, fmt) . map ( Variant :: Symbol )
394
387
}
395
388
codec:: FORMATCODE_LIST0 => Ok ( Variant :: List ( List ( vec ! [ ] ) ) ) ,
396
- codec:: FORMATCODE_LIST8 => List :: decode_with_format ( input, fmt) . map ( Variant :: List ) ,
397
- codec:: FORMATCODE_LIST32 => List :: decode_with_format ( input, fmt) . map ( Variant :: List ) ,
398
- codec:: FORMATCODE_MAP8 => HashMap :: < Variant , Variant > :: decode_with_format ( input, fmt)
399
- . map ( |o| Variant :: Map ( VariantMap :: new ( o) ) ) ,
400
- codec:: FORMATCODE_MAP32 => HashMap :: < Variant , Variant > :: decode_with_format ( input, fmt)
401
- . map ( |o| Variant :: Map ( VariantMap :: new ( o) ) ) ,
389
+ codec:: FORMATCODE_LIST8 | codec:: FORMATCODE_LIST32 => {
390
+ List :: decode_with_format ( input, fmt) . map ( Variant :: List )
391
+ }
392
+ codec:: FORMATCODE_ARRAY8 | codec:: FORMATCODE_ARRAY32 => {
393
+ Array :: decode_with_format ( input, fmt) . map ( Variant :: Array )
394
+ }
395
+ codec:: FORMATCODE_MAP8 | codec:: FORMATCODE_MAP32 => {
396
+ HashMap :: < Variant , Variant > :: decode_with_format ( input, fmt)
397
+ . map ( |o| Variant :: Map ( VariantMap :: new ( o) ) )
398
+ }
402
399
codec:: FORMATCODE_DESCRIBED => {
403
400
let descriptor = Descriptor :: decode ( input) ?;
404
401
let value = Variant :: decode ( input) ?;
405
402
Ok ( Variant :: Described ( ( descriptor, Box :: new ( value) ) ) )
406
403
}
407
- codec:: FORMATCODE_ARRAY8 | codec:: FORMATCODE_ARRAY32 => {
408
- Err ( AmqpParseError :: ArrayTypeIsNotSupported )
409
- }
410
404
_ => Err ( AmqpParseError :: InvalidFormatCode ( fmt) ) ,
411
405
}
412
406
}
@@ -475,7 +469,10 @@ fn decode_frame_header(input: &mut Bytes, expected_frame_type: u8) -> Result<u16
475
469
Ok ( channel_id)
476
470
}
477
471
478
- fn decode_array_header ( input : & mut Bytes , fmt : u8 ) -> Result < CompoundHeader , AmqpParseError > {
472
+ pub ( crate ) fn decode_array_header (
473
+ input : & mut Bytes ,
474
+ fmt : u8 ,
475
+ ) -> Result < CompoundHeader , AmqpParseError > {
479
476
match fmt {
480
477
codec:: FORMATCODE_ARRAY8 => decode_compound8 ( input) ,
481
478
codec:: FORMATCODE_ARRAY32 => decode_compound32 ( input) ,
0 commit comments