librasn / rasn

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

feature: Support Empty Choices #186

Closed 6d7a closed 5 months ago

6d7a commented 8 months ago

ASN1 allows for empty CHOICE types. Currently, rasn doesn't handle this case properly.

When trying to compile the CHOICE below...

    #[derive(AsnType, Decode, Encode, Debug, Clone, Copy, PartialEq)]
    #[rasn(choice)]
    #[rasn(crate_root = "crate")]
    enum EmptyChoice {
    }

...the error error[E0004]: non-exhaustive patterns: type&EmptyChoiceis non-empty is thrown.

6d7a commented 8 months ago

I'll try to provide a fix for it.

6d7a commented 5 months ago

Rereading ITU-T X.680 §29, I realized that empty choices are illegal after all.