Derive Macro der::Choice [−][src]
#[derive(Choice)] { // Attributes available to this derive: #[asn1] }
This is supported on crate feature
derive
only.Derive the Choice
trait on an enum.
This custom derive macro can be used to automatically impl the
Decodable
and Encodable
traits along with the
Choice
supertrait for any enum representing an ASN.1 CHOICE
.
The enum must consist entirely of 1-tuple variants wrapping inner
types which must also impl the Decodable
and Encodable
traits. It will will also generate From
impls for each of the
inner types of the variants into the enum that wraps them.
Usage
ⓘ
// NOTE: requires the `derive` feature of `der` use der::Choice; /// `Time` as defined in RFC 5280 #[derive(Choice)] pub enum Time { #[asn1(type = "UTCTime")] UtcTime(UtcTime), #[asn1(type = "GeneralizedTime")] GeneralTime(GeneralizedTime), }
#[asn1(type = "...")]
attribute
See toplevel documentation for the der_derive
crate for more
information about the #[asn1]
attribute.