@@ -386,6 +386,7 @@ pub enum ComponentDefinedType<'a> {
386386 Record ( Record < ' a > ) ,
387387 Variant ( Variant < ' a > ) ,
388388 List ( List < ' a > ) ,
389+ Map ( Map < ' a > ) ,
389390 FixedSizeList ( FixedSizeList < ' a > ) ,
390391 Tuple ( Tuple < ' a > ) ,
391392 Flags ( Flags < ' a > ) ,
@@ -407,6 +408,8 @@ impl<'a> ComponentDefinedType<'a> {
407408 Ok ( Self :: Variant ( parser. parse ( ) ?) )
408409 } else if l. peek :: < kw:: list > ( ) ? {
409410 parse_list ( parser)
411+ } else if l. peek :: < kw:: map > ( ) ? {
412+ Ok ( Self :: Map ( parser. parse ( ) ?) )
410413 } else if l. peek :: < kw:: tuple > ( ) ? {
411414 Ok ( Self :: Tuple ( parser. parse ( ) ?) )
412415 } else if l. peek :: < kw:: flags > ( ) ? {
@@ -451,6 +454,7 @@ impl Peek for ComponentDefinedType<'_> {
451454 Some ( ( "record" , _) )
452455 | Some ( ( "variant" , _) )
453456 | Some ( ( "list" , _) )
457+ | Some ( ( "map" , _) )
454458 | Some ( ( "tuple" , _) )
455459 | Some ( ( "flags" , _) )
456460 | Some ( ( "enum" , _) )
@@ -587,6 +591,15 @@ pub struct List<'a> {
587591 pub element : Box < ComponentValType < ' a > > ,
588592}
589593
594+ /// A map type.
595+ #[ derive( Debug ) ]
596+ pub struct Map < ' a > {
597+ /// The key type of the map.
598+ pub key : Box < ComponentValType < ' a > > ,
599+ /// The value type of the map.
600+ pub value : Box < ComponentValType < ' a > > ,
601+ }
602+
590603/// A fixed size list type.
591604#[ derive( Debug ) ]
592605pub struct FixedSizeList < ' a > {
@@ -612,6 +625,18 @@ fn parse_list<'a>(parser: Parser<'a>) -> Result<ComponentDefinedType<'a>> {
612625 }
613626}
614627
628+ impl < ' a > Parse < ' a > for Map < ' a > {
629+ fn parse ( parser : Parser < ' a > ) -> Result < Self > {
630+ parser. parse :: < kw:: map > ( ) ?;
631+ let key = parser. parse ( ) ?;
632+ let value = parser. parse ( ) ?;
633+ Ok ( Self {
634+ key : Box :: new ( key) ,
635+ value : Box :: new ( value) ,
636+ } )
637+ }
638+ }
639+
615640/// A tuple type.
616641#[ derive( Debug ) ]
617642pub struct Tuple < ' a > {
0 commit comments