-
Notifications
You must be signed in to change notification settings - Fork 72
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
Feature request: per-container prefix #641
Comments
I am not sure it, this works well as a container attribute. It seems like you want this prefix to apply recursively, i.e., in the case of Overall, I am open to providing some rename capabilities. From time to time, there are feature requests to serde for different patterns. A rename macro would place a matching |
Ideally, yes, it'd be recursive. But thinking on it further, that'd probably be very hard (if at all possible). Single-level implementation would still be very useful. I haven't looked at your sources, are those proc macros or regular ones? I must profess to have no experience with either. |
You would need a proc-macro for this to work because you would need various computations to be executed at compile time. Getting started with proc-macros is quite a bit, due to the very specific nature and the needed crates. Otherwise, the proc-macro wouldn't be too complicated. It needs to go over all fields and find all the prefix/suffix/rename rules and combine them. Beside prefixes, the macro could collect other rename patterns, like serde-rs/serde#2571 or serde-rs/serde#2657 or serde-rs/serde#1724. |
Rather than set the prefix at the point of use, I'd like to set it on a container, essentially just prepending it to the
rename
value for all fields.My use case is working with Wireshark's packet dissection JSON, which likes to prepend an object's name to all the field names inside said object, although the prefix is not always exact.
TBH, I'm not sure if this feature is better suited here, or in
serde
proper.The text was updated successfully, but these errors were encountered: