librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
183 stars 43 forks source link

Feat/identifier annotation #239

Closed 6d7a closed 3 months ago

6d7a commented 3 months ago

This is related to compiler issue #6.

Text-based encoding rules use type names in their encoding of ASN.1 types. The type names in rasn bindings may not be the same as in the original spec. Certain type names - for example those that contain hyphens - are not acceptable as identifiers in rust, at all. This PR adds a new identifier annotation to retain the original names in rasn bindings.

XAMPPRocky commented 3 months ago

Thank you for your PR! This all looks good to me, but I don't see mention of why the JER codec is replacing hyphens with underscores, can you explain that part?

6d7a commented 3 months ago

Sure. That conversion is a requirement of JER itself. From the JER spec: "An ASN.1 identifier is also a valid JavaScript identifier name if and only if it does not contain any hyphens. This makes the conversion rule simple: convert any hyphen into an underscore"