Apply rename_all casing to RPC parameter names including a compat shim#63
Open
Eligioo wants to merge 3 commits into
Open
Apply rename_all casing to RPC parameter names including a compat shim#63Eligioo wants to merge 3 commits into
rename_all casing to RPC parameter names including a compat shim#63Eligioo wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend
#[service(rename_all = …)]and#[proxy(rename_all = …)]to rename RPC parameter names on the JSON wire including an automatic alias in order to retain backwards compatibility.This PR supersedes #30 as it's non-breaking.
The three commits:
rename_allconvention as method names (e.g.first_operand→firstOperand).serdealias for backward compatibility — instead of renaming the Rust identifier, the macro keeps identssnake_caseand emits#[serde(rename = "<new>", alias = "<old>")]per field. Servers therefore will accept both the new and the original name during the migration window. This also fixes a compile-time panic forrename_all = "kebab-case"(a hyphen is not a valid Rust identifier).log::warn!per request when a request still uses a pre-rename parameter name. Is a no-op when no params were renamed.Examples
Old style still being accepted when
rename_allis set tocamelCasebecause of the alias for compatibility. Note: in this case alog::warnis outputted on the server side since at least one parameter isn't in camel case.New style is also supported when
rename_allis set tocamelCase