Color -> Tui
Parse hex colors to tui rgb colors
#c3f111
-> Color::Rgb(195,241,17)
Note that the indexed colors are NOT HEX
#142
-> Color::Indexed(142)
Example
#[derive(Serialize, Deserialize, PartialEq)]
sruct ColorStruct {
#[serde(with = "color-parser-tui"]
color: tui::style::Color,
#[serde(with = "color-parser-tui::optional"]
optional_color: Option<tui::style::Color>,
}
let color_text = r###"{ "color" : "#12FC1C", "optional_color" : "#123" }"###
let t: ColorStruct = serde_json::from_str::<ColorStruct>(color_text).unwrap();
let c = ColorStruct {
color: Color::Rgb(18, 252, 28),
optional_color: Option<Color::Indexed(123)>,
};
assert_eq!(t, c);