Skip to content

Reducing common structs types or https://github.com/kube-rs/gateway-api-rs/issues/38 #147

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dawid-nowak
Copy link
Contributor

@dawid-nowak dawid-nowak commented Jun 9, 2025

This approach aims to simplify the types and eliminate redundant ones. The approach works as follows:

  1. We scan generated files and find similar items (structs or enums). Two structs are considered to be similar and processed further if their fields are exactly the same. The same method applies to the enums.
  2. Once all similar structs and enums have been found, then we try get the name that will applied to similar structs from a file.
  3. Once the new type names are settled we change the generated code and add a new file with the reduced types "common_types.rs"

We follow this process in phases:

  1. In Phase 1, we only look at the structs with fields which are built from simple types (String, u32, u64)
  2. In Phase 2, we also look at the structs with fields that have been changed in Phase 1
  3. and repeat

Problems:

  1. The documentation is stripped since the same type could be used in many different locations

Signed-off-by: Dawid Nowak <[email protected]>
@dawid-nowak dawid-nowak force-pushed the reducing_common_structs_types branch 3 times, most recently from ea15d03 to a974d67 Compare June 11, 2025 20:27
@dawid-nowak dawid-nowak force-pushed the reducing_common_structs_types branch from a974d67 to 9958589 Compare June 11, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant