Skip to content

serde compatibility #44

@carlocorradini

Description

@carlocorradini

serde compatibility could be extremely useful (like with ts_rs).
The 'Difference' macro should recognize some serde attributes (such as rename or rename_all) and add them to the resulting difference enum.

#[derive(Serialize, Deserialize, Difference)]
#[serde(rename_all(serialize = "camelCase"))]
#[difference(expose = "ExampleDiff")]
struct Example {
    pub id: String,
    pub date_of_birthday: String,    // dateOfBirthday
    #[serde(rename = "updatedAt")]
    pub update: String,              // updatedAt
}

Given the previous example, the resulting ExampleDiff enum should have the attribute #[serde(rename_all(serialize = "camelCase"))] and its update variant the attribute #[serde(rename = "updatedAt")].
This ensures that the Example struct and ExampleDiff enum are in sync with their ser(de) counterparts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions