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

Create separate templates based on AbstractDataType for struct.templ #93

Open
desaikd opened this issue Mar 20, 2024 · 1 comment
Open
Labels
code generation Improvements for code generation subcommand `generate`

Comments

@desaikd
Copy link
Contributor

desaikd commented Mar 20, 2024

Currently struct.templ has if statements that help render a Rust struct based on AbstractDataType value. Instead generate different modules for ease of code maintenance and reviewer's readability.

@desaikd desaikd added the code generation Improvements for code generation subcommand `generate` label Mar 20, 2024
@desaikd
Copy link
Contributor Author

desaikd commented Mar 20, 2024

So, that is why I mentioned WriteAsIon in one of my other comments. WriteAsIon is already implemented for primitive types and for Vec<T: WriteAsIon>, and if we don't have an equivalent ReadFromIon or similar, then we need to create an issue for that in ion-rust.

On the other hand, I think there could also be reason to use wrapper if we want to add additional validation constraints, such as type::{ name: small_int, type: int, valid_values: range::[0, 9] }. In that case having struct SmallInt(u8) would actually allow us to add the range check to the type. That being said, I can't remember if we decided whether we want to ever have additional validations like that.

#90 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code generation Improvements for code generation subcommand `generate`
Projects
Status: No status
Development

No branches or pull requests

1 participant