[][src]Macro rustbus::dbus_variant_sig

macro_rules! dbus_variant_sig {
    ($vname: ident, $($name: ident => $typ: path);+) => { ... };
}

This macro provides a convenient way to create enums to represent relatively simple Variants, with fitting marshal/unmarshal implementations. It can be used like this:

   type Map = std::collections::HashMap<String, (i32, u8, (u64, MyVariant))>;
   type Struct = (u32, u32, MyVariant);
   dbus_variant_sig!(MyVariant, CaseMap => Map; CaseStruct => Struct);

And it will generate an enum like this:

enum MyVariant {
    CaseMap(Map),
    CaseStruct(Struct),
    Catchall(rustbus::signature::Type),   
}

The Catchall case is used for unmarshalling, when encountering a Value that did not match any of the other cases. The generated marshal impl will refuse to marshal the Catchall case! If you want to have a case for a signature you need to make it explicitly.

Current limitations

  1. References like &str are not supported