Module asn1_cereal::ber::serial::choice
[−]
[src]
Macros to generate the implementation of the serialization traits for Rust enums, as ASN.1 choice.
You can either define both asn1_info!
and ber_choice!
, or all three
of asn1_info!
, ber_choice_serialize!
and ber_choice_deserialize!
.
#[macro_use] extern crate asn1_cereal; fn main() { enum Enum1 { A(u64), B(String), }; enum Enum2 { A(u64), B(u64), }; // A choice type with no tag. // CHOICE { a INTEGER, b PRINTABLE STRING } ber_choice!(Enum1, "CHOICE", A, u64; B, String;); // OR // A choice type with a custom tag on a variant. // CHOICE { a INTEGER, b [0] INTEGER } asn1_info!(Enum2, "CHOICE2"); ber_choice_serialize!(Enum2, A, u64; B, u64;); ber_choice_deserialize!(Enum2, A, u64; [0] B, u64;); }Run