macro_rules! thrift_union {
($(#[$($def_attrs:tt)*])* union $identifier:ident $(< $lt:lifetime >)? { $($(#[$($field_attrs:tt)*])* $field_id:literal : $( ( $field_type:ident $(< $element_type:ident >)? $(< $field_lt:lifetime >)?) )? $field_name:ident $(;)?)* }) => { ... };
}
Expand description
Macro used to generate Rust enums for Thrift unions where variants are a mix of unit and tuple types.
Use of this macro requires modifying the thrift IDL. For variants with empty structs as their
type, delete the typename (i.e. 1: EmptyStruct Var1;
becomes 1: Var1
). For variants with a
non-empty type, the typename must be contained within parens (e.g. 1: MyType Var1;
becomes
1: (MyType) Var1;
).
This macro allows for specifying lifetime annotations for the resulting enum
and its fields.
When utilizing this macro the Thrift serialization traits and structs need to be in scope.