macro_rules! thrift {
($(#[$($def_attrs:meta)*])* struct $identifier:ident { $($definitions:tt)* } $($remainder:tt)*) => { ... };
($(#[$($def_attrs:meta)*])* union $identifier:ident { $($definitions:tt)* } $($remainder:tt)*) => { ... };
($(#[$($def_attrs:meta)*])* enum $identifier:ident { $($definitions:tt)* } $($remainder:tt)*) => { ... };
($(#[$($def_attrs:meta)*])* namespace $identifier:ident $namespace:ident $($remainder:tt)*) => { ... };
() => { ... };
}Expand description
Parse several thrift struct / union / enum / namespace definitions and generate the corresponding Rust types and code to read and write those types.
See the thrift_struct / thrift_union / thrift_enum macros for details of the
accepted syntax.
Implementation notes:
This uses the incremental tt muncher pattern to process the first thrift definition and then recursively calls itself to process the remainder.
Field definitions are handled as token trees in this macro, the more specific thrift_struct,
thrift_union and thrift_enum macros destructure those trees.
The $(#[$($def_attrs:meta)*])* pattern matches any number of attributes on those structures.
The rust compiler internally treats doc comments as #[doc = ""] attributes,
this pattern allows to keep comments in the generated code.