ENUM_DESC & ENUM_TRS
A set of column-derived macros is provided to add descriptive information to enumerations and facilitate the translation of enumeration codes.
Specifically, the following macros serve to augment enums with additional functionality:
"EnumDesc", "EnumDescI8", "EnumDescU8", "EnumDescI16", "EnumDescU16", "EnumDescI32", "EnumDescU32", "EnumDescI64", "EnumDescU64", "EnumDescISize", "EnumDescUSize"
The enum_trs attribute macro, on the other hand, enables the translation of values, supporting both "equivalent translation" and "flag translation."
EXAMPLE - EnumDesc
Add descriptive information to enumerations
Run the code above, and you will see the following information:
enum: Some(PHONE)
code: 2
desc: "host computer"
desc: "tablet"
EXAMPLE - enum_trs
Translate enumeration codes
/// Ordinary Enumeration
/// Flagged Bit Enumeration,
/// "=" is used for equivalent translation
/// "&" is used for flag bit translation.
Run the code above, and you will see the following information:
UserDto {
name: "hui",
gender: 1,
allow_device_type: Some(
7,
),
gender_desc: "female",
allow_device_type_desc: "mobile phone | host computer | tablet",
}