1 //! ASN.1 `CHOICE` support.
3 use crate::{Decode, FixedTag, Tag, Tagged}
;
5 /// ASN.1 `CHOICE` denotes a union of one or more possible alternatives.
7 /// The types MUST have distinct tags.
9 /// This crate models choice as a trait, with a blanket impl for all types
10 /// which impl `Decode + FixedTag` (i.e. they are modeled as a `CHOICE`
11 /// with only one possible variant)
12 pub trait Choice
<'a
>: Decode
<'a
> + Tagged
{
13 /// Is the provided [`Tag`] decodable as a variant of this `CHOICE`?
14 fn can_decode(tag
: Tag
) -> bool
;
17 /// This blanket impl allows any [`Tagged`] type to function as a [`Choice`]
18 /// with a single alternative.
19 impl<'a
, T
> Choice
<'a
> for T
21 T
: Decode
<'a
> + FixedTag
,
23 fn can_decode(tag
: Tag
) -> bool
{