So, once again, a major update - pub fn zonToStruct
now returns an auto-generated struct with fields that indicate whether their corresponding fields in the target struct were filled or not. Previously there was no way to tell if the field was assigned to or not.
At first I was thinking about a lightweight (no conditionals, etc.) schema, but then I thought it’s too much hassle for the user, and for me, and that they can simply check the result and decide whether it’s OK or not.
Fields of this “report” struct are enums of ZonFieldResult
type - unless they are sub-structs, arrays, arrays of sub-structs, arrays of arrays, that ultimately end up being composed of the same ZonFieldResult
enums.
They can indicate either that the field was not_filled
or filled
, and in the case of arrays - if there was not enough values in ZON / AST (partially_filled
) or too many values (overflow_filled
).
Slices are either not_filled
or filled
, simple , since fn zonToStruct
has to allocate them dynamically anyway, there’s no such thing as not enough values or too many. A slice represented with one ZonFieldResult
field in the report struct.
Sadly, this means that if it’s a slice of structs, for example, you don’t get information on the individual fields of these structs. Oh well, maybe in the future I’ll come up with something to remedy this.
In the meantime, I think I’ll take a break from this little project.