Macro eagre_asn1::der_enumerated [] [src]

macro_rules! der_enumerated {
    ($enum_name:ident, $($enum_variant:ident),+) => { ... };
    ($enum_name:ident, $($enum_val:ident),+,) => { ... };
}

Macro to create enumeration implementation for enum

Example


enum EventType {
    Keyboard = 12,
    Mouse = 10,
    Update = 1,
    Timer = 42,
}

der_enumerated!(EventType, Keyboard, Mouse, Update, Timer);

let event = EventType::Timer;
let encoded = event.der_bytes().unwrap();
// Send to far away planet
let decoded = EventType::der_from_bytes(encoded).unwrap();
assert_eq!(event, decoded);