macro_rules! request_enum {
    ($(#[$attrs:meta])* $enu:ident | $($evt_name:ident => $iface:ty),*) => { ... };
    ($(#[$attrs:meta])* $enu:ident | $($evt_name:ident => $iface:ty),* | $($name:ident => $value:ty),*) => { ... };
}
Expand description

Generate an enum joining several objects requests

This macro allows you to easily create a enum type for use with your message Filters. It is used like so:

request_enum!(
    MyEnum |
    Pointer => WlPointer,
    Keyboard => WlKeyboard,
    Surface => WlSurface
);

This will generate the following enum, unifying the requests from each of the provided interface:

pub enum MyEnum {
    Pointer { request: WlPointer::Request, object: Main<WlPointer> },
    Keyboard { request: WlKeyboard::Request, object: Main<WlKeyboard> },
    Surface { request: WlSurface::Request, object: Main<WlSurface> }
}

It will also generate the appropriate From<_> implementation so that a Filter<MyEnum> can be used as assignation target for WlPointer, WlKeyboard and WlSurface.

If you want to add custom messages to the enum, the macro also supports it:

request_enum!(
    MyEnum |
    Pointer => WlPointer,
    Keyboard => WlKeyboard,
    Surface => WlSurface |
    MyMessage => SomeType,
    OtherMessage => OtherType
);

will generate the following enum:

pub enum MyEnum {
    Pointer { request: WlPointer::Request, object: Main<WlPointer> },
    Keyboard { request: WlKeyboard::Request, object: Main<WlKeyboard> },
    Surface { request: WlSurface::Request, object: Main<WlSurface> },
    MyMessage(SomeType),
    OtherMessage(OtherType)
}

as well as implementations of From<SomeType> and From<OtherType>, so that these types can directly be provided into a Filter<MyEnum>.