librasn / compiler

An ASN1 compiler producing Rust bindings for the rasn framework
Other
13 stars 7 forks source link

RFC: use FixedOctetString in relevant cases #42

Closed kurkpitaine closed 1 month ago

kurkpitaine commented 1 month ago

This is not an issue, but a proposal for improvement.

Currently, the compiler output assign Rasn's OctetString type for all Asn.1 OctetString fields. Rasn library has a FixedOctetString<N> type which can be used to represent strictly constrained OctetString, ie: my_field OCTET STRING(SIZE (8)) would be FixedOctetString<8> in generated code. Benefits of the usage of FixedOctetString is the guarantee of the size constraint respect, since it is statically checked by the compiler and stack allocation instead of heap.

6d7a commented 1 month ago

Good point! Thank you for your proposal. Release v0.5.2 will generate rasn bindings hat use FixedOctetString and FixedBitString.

kurkpitaine commented 1 month ago

Wow! I did not expect this fast answer! In fact, I started looking at patching the code 😄 Thank you very much!

Apart from Asn.1 stuff, I see you work on V2x stuff. As I do for the last 10 years around projects in France and Europe. I started a Rust #![no_std] implementation of ETSI Geonetworking, as a challenge to learn Rust and overcome some s****y commercial implementations. Feel free to look at it.