feat(serializer): 添加将Oklch颜色序列化为十六进制字符串的功能
This commit is contained in:
parent
a77fb3f18b
commit
f82575c49b
12
color-module/src/foreign_serializer.rs
Normal file
12
color-module/src/foreign_serializer.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use palette::Oklch;
|
||||
use serde::Serializer;
|
||||
|
||||
use crate::convert::map_oklch_to_srgb_hex;
|
||||
|
||||
pub fn serialize_oklch_to_hex<S>(color: &Oklch, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let hex_color = map_oklch_to_srgb_hex(color);
|
||||
serializer.serialize_str(&hex_color)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user