This fixes a long-standing bug in how Alpha and PreAlpha are serialized. They used to be flattened to a map, which is fine in JSON but not in more expressive formats, such as RON. The replacement implementation will only handle a subset of possible values (structs, tuples and sequences), but they should be the most common ones. It should also be possible to extend it later.
I have also taken the opportunity to add some helpful utility functions for serializing and de-serializing.
Closed Issues
Fixes #130, using a custom implementation.
Breaking Change
Technically breaking, since it changes the serialization format a bit, but the old behavior was buggy and not always usable. The serialized type and name for Alpha and PreAlpha is now inherited from the color's type. So, for example, Srgba will be serialized and de-serialized as an Rgb struct with an additional alpha field. Unit types get extended to newtypes, and newtypes get extended to tuples.
This fixes a long-standing bug in how
Alpha
andPreAlpha
are serialized. They used to be flattened to a map, which is fine in JSON but not in more expressive formats, such as RON. The replacement implementation will only handle a subset of possible values (structs, tuples and sequences), but they should be the most common ones. It should also be possible to extend it later.I have also taken the opportunity to add some helpful utility functions for serializing and de-serializing.
Closed Issues
Breaking Change
Technically breaking, since it changes the serialization format a bit, but the old behavior was buggy and not always usable. The serialized type and name for
Alpha
andPreAlpha
is now inherited from the color's type. So, for example,Srgba
will be serialized and de-serialized as anRgb
struct with an additionalalpha
field. Unit types get extended to newtypes, and newtypes get extended to tuples.