css-colors
css-colors copied to clipboard
Add serde support
What about to add serde support?
extern crate serde;
extern crate serde_json;
extern crate serde_derive;
extern crate css_colors;
use css_colors::{RGB, rgb};
use serde_derive::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct Example {
color: RGB,
}
#[test]
fn example() {
let example = Example {
color: rgb(100, 200, 1),
};
let json = serde_json::to_string(&example).unwrap();
assert!(json, "{\"color\":\"rgb(100,200,1)\"}");
}
This would be a nice addition indeed, I could give it a try.
Best would be support of hex codes (in both short #abc and long #abcdef form) for RGB. The 8-hex version for RGBA is not standardised, but could be added as well.