linebender / color

Color in Rust.
Apache License 2.0
39 stars 5 forks source link

Optionally support `serde`. #61

Closed waywardmonkeys closed 6 days ago

waywardmonkeys commented 1 week ago

This adds support for serde::Deserialize and serde::Serialize using serde-derive for AlphaColor, OpaqueColor, PremulColor, Rgba8.

This does not provide it for DynamicColor to avoid dealing with the non-exhaustive ColorSpaceTag.

It uses derive rather than hand-implementing the traits as the latter is very verbose and most things using serde will already have enabled the derive feature. (This is also true for the other Linebender crates.)

waywardmonkeys commented 1 week ago

The fact that this uses the derive feature for serde doesn't change the decision to not use it for bytemuck.

In particular, crates like resvg, tiny-skia, and those from Makepad do use bytemuck, don't use serde and very much do not want a dependency on the whole proc macro world that serde-derive builds on.