File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,18 @@ macro_rules! asn1 {
8
8
) ;
9
9
10
10
( @field_type [ $( $parsed: tt) * ] [ INTEGER , $( $rest: tt) * ] ) => (
11
- asn1!( @field_name [ $( $parsed) * @type INTEGER ] [ $( $rest) * ] ) ;
11
+ asn1!( @field_name [ $( $parsed) * @type INTEGER @rust_type i64 ] [ $( $rest) * ] ) ;
12
12
) ;
13
13
( @field_type [ $( $parsed: tt) * ] [ BOOLEAN , $( $rest: tt) * ] ) => (
14
- asn1!( @field_name [ $( $parsed) * @type BOOLEAN ] [ $( $rest) * ] ) ;
14
+ asn1!( @field_name [ $( $parsed) * @type BOOLEAN @rust_type bool ] [ $( $rest) * ] ) ;
15
15
) ;
16
16
17
- ( @complete $name: ident $( , @name $field_name: ident @type $field_type: ty) * ) => {
18
- struct $name;
17
+ ( @complete $name: ident $( , @name $field_name: ident @type $field_type: ident @rust_type $field_rust_type) * ) => {
18
+ struct $name {
19
+ $(
20
+ $field_name: $field_rust_type,
21
+ ) *
22
+ }
19
23
20
24
impl $name {
21
25
fn asn1_description( ) -> Vec <( & ' static str , & ' static str ) > {
@@ -70,4 +74,18 @@ mod tests {
70
74
( "y" , "BOOLEAN" ) ,
71
75
] )
72
76
}
77
+
78
+ #[ test]
79
+ fn test_struct ( ) {
80
+ asn1 ! (
81
+ Double :: = SEQUENCE {
82
+ x INTEGER ,
83
+ y BOOLEAN ,
84
+ }
85
+ ) ;
86
+
87
+ let d = Double { x : 3 , y : true } ;
88
+ assert_eq ! ( d. x, 3 ) ;
89
+ assert_eq ! ( d. y, true ) ;
90
+ }
73
91
}
You can’t perform that action at this time.
0 commit comments