formats icon indicating copy to clipboard operation
formats copied to clipboard

der: derive(Choice) needs `constructed = "true"` flag

Open dishmaker opened this issue 9 months ago • 0 comments

derive(Choice) needs constructed = "true" flag, but derive(Sequence) does not.


#[derive(Choice)]
pub enum ImplicitChoice<'a> {
    // This works:
    #[asn1(context_specific = "3", tag_mode = "IMPLICIT", constructed = "true")]
    SequenceOfNulls(SequenceOf<Null, 1>),

    // This won't decode:
    #[asn1(context_specific = "3", tag_mode = "IMPLICIT")]
    SequenceOfNulls(SequenceOf<Null, 1>),
}

I mean, the Choice macro is clueless about the underlaying type.

Something like this is possible:

let tag: Tag = Tag::Utf8String;
match tag {
    String::TAG => {}
    Null::TAG => {}
    SequenceOf::<Null, 1>::TAG => {}
    // .. more choices
}

dishmaker avatar May 05 '25 09:05 dishmaker