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

Formal specification of Smithy -> Rust identifier mapping #2340

Open
hlbarber opened this issue Feb 9, 2023 · 0 comments
Open

Formal specification of Smithy -> Rust identifier mapping #2340

hlbarber opened this issue Feb 9, 2023 · 0 comments
Labels
client server Rust server SDK

Comments

@hlbarber
Copy link
Contributor

hlbarber commented Feb 9, 2023

Identifiers in the Smithy models are mapped to identifiers in Rust via SymbolProviders.

The details of this mapping are not formally described. Perhaps the simplest proposal is to preserve all identifiers modulo escaping reserved words. This should be the subject of an RFC.

A mapping is said to be collision free if it maps no two elements to the same output.

Topics

  • Should this be configurable?
  • The BNF for Rust identifiers vs the BNF for Smithy identifiers
  • What should be the exact behavior of escaping reserved words? Is this collision free?
  • enum variants in Rust are PascalCase, whereas Smithy enum variants are SCREAMING_SNAKE_CASE.
  • Pros/Cons of preserving the identifiers:
    • General AWS documentation uses the model identifiers.
    • Prior art e.g. what do other code generators do? bindgen, tonic etc.
    • Simplicity?
    • Conflict free?
    • Breaking change
    • Can make Rust code look ugly
  • If such a scheme does include conflicts they should be classified and documented.
  • Are there cases where we 100% don't want to preserve identifiers? For example operation names to setters (snake_case). In this scenario can we prevent collisions?
  • Methods to ensure that developers stick to guidelines.
    • Forbid ToString on the type level?
    • Lint to catch such conversions?
    • rustTemplate prohibits string interpolation?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client server Rust server SDK
Projects
None yet
Development

No branches or pull requests

1 participant