thrift_union_all_empty

Macro thrift_union_all_empty 

Source
macro_rules! thrift_union_all_empty {
    ($(#[$($def_attrs:tt)*])* union $identifier:ident { $($(#[$($field_attrs:tt)*])* $field_id:literal : $field_type:ident $(< $element_type:ident >)? $field_name:ident $(;)?)* }) => { ... };
}
Expand description

Macro used to generate Rust enums for Thrift unions in which all variants are typed with empty structs.

Because the compact protocol does not write any struct type information, these empty structs become a single 0 (end-of-fields marker) upon serialization. Rather than trying to deserialize an empty struct, we can instead simply read the 0 and discard it.

The resulting Rust enum will have all unit variants.

When utilizing this macro the Thrift serialization traits and structs need to be in scope.