内置注解
@rename
Section titled “@rename”@rename("...") 用来重命名字段的序列化名字。
- 作用于
struct/union成员 - 生成 HTTP / JSON 映射时会把它当作 wire / property name
- 生成 Rust 时通常映射为
#[serde(rename = \"...\")]
示例:
struct User { uint32 id; @name("new_name") string name;};@rename_all
Section titled “@rename_all”@rename_all("...") 允许重命名所有字段的名字。
@rename_all("snake_case")struct User { uint32 id; string name;};支持的参数如下:
- lowercase
- UPPERCASE
- PascalCase
- camelCase
- snake_case
- SCREAMINGSNAKECASE
- kebab-case
- SCREAMING-KEBAB-CASE