impl_try_from_event_for_interface_enum

Macro impl_try_from_event_for_interface_enum 

Source
macro_rules! impl_try_from_event_for_interface_enum {
    ($outer_type:ty, $outer_variant:path) => { ... };
}
Expand description

Expands to a conversion given the enclosed event enum type and outer Event variant.

eg

impl_try_from_event_for_interface_enum!(ObjectEvents, Event::Object);

expands to:

impl TryFrom<Event> for ObjectEvents {
    type Error = AtspiError;
    fn try_from(generic_event: Event) -> Result<ObjectEvents, Self::Error> {
        if let Event::Object(event_type) = generic_event {
            Ok(event_type)
        } else {
            Err(AtspiError::Conversion("Invalid type"))
        }
    }
}