You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The best solution to this problem might actually a code style convention for Annatto (maybe even some kind of doc string template for fields) that forces contributors to mention TYPE and IS_REQUIRED (or whatever) in the doc string.
Parsing field types and even worse, figuring out if they are required, seem to be sth undesirable in a language like Rust.
Another approach to think about a little bit is to refrain from using defaults for deserializable struct fields except for Option, thus using the latter would be a clear indicator of a field not being required. This, though, would have some weird implication for primitive types. bool as a type could be replaced by anything, since we'd only need to check for None vs. Some. For integer types, would we assume a difference between 0 and None or None always implies 0? As stated above, this needs some thinking about. On the contrary, we could not restrict types but always enforce there is a default, which does not work for path types (so we'd have to explicitly code around it) and does not make sense in all contexts (e. g. layer and name of annotation component arguments, the type usually can be thought of in default terms).
Activity
MartinKl commentedon Jun 24, 2024
The best solution to this problem might actually a code style convention for Annatto (maybe even some kind of doc string template for fields) that forces contributors to mention TYPE and IS_REQUIRED (or whatever) in the doc string.
Parsing field types and even worse, figuring out if they are required, seem to be sth undesirable in a language like Rust.
MartinKl commentedon Jun 24, 2024
Another approach to think about a little bit is to refrain from using defaults for deserializable struct fields except for
Option, thus using the latter would be a clear indicator of a field not being required. This, though, would have some weird implication for primitive types.boolas a type could be replaced by anything, since we'd only need to check forNonevs.Some. For integer types, would we assume a difference between0andNoneorNonealways implies0? As stated above, this needs some thinking about. On the contrary, we could not restrict types but always enforce there is a default, which does not work for path types (so we'd have to explicitly code around it) and does not make sense in all contexts (e. g. layer and name of annotation component arguments, the type usually can be thought of in default terms).MartinKl commentedon Jun 25, 2024
The current policy is to enforce default. Where defaut is not possible for fields, use Option