Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename field attribute, passing a path instead of literal #2725

Open
softstream-link opened this issue Apr 2, 2024 · 0 comments
Open

rename field attribute, passing a path instead of literal #2725

softstream-link opened this issue Apr 2, 2024 · 0 comments

Comments

@softstream-link
Copy link

I would like to be able to but not sure if rename is able to accept anything but literal

trait FiedlMetaData{
   const TAG_NAME: 'static &str;
   .....
}
#[derive(Serialize, Deserialize)]
struct Amount{
 ...
}
impl FieldMetaData for Amount{
 const TAG_NAME: 'static &str = "3";
}
struct Sequence{
 ...
}
impl FieldMetaData for Sequence{
 const TAG_NAME: 'static &str = "6";
}
#[derive(Serialize, Deserialize)]
struct Msg{
   #[serde(rename = Amount::TAG_NAME)]
   field_a: Amount,
   #[serde(rename = Sequence::TAG_NAME)]
   field_b: Sequence, 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant