1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![cfg(feature = "serde")]
//! Serde support for serializing
//! crate datastructures
//!
//! Implements serialize for
//!  - ColorSpace
//!  - BitDepth
//!  - ColorCharacteristics
use alloc::format;

use serde::ser::*;

use crate::bit_depth::BitDepth;
use crate::colorspace::{ColorCharacteristics, ColorSpace};

impl Serialize for ColorSpace
{
    #[allow(clippy::uninlined_format_args)]
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer
    {
        // colorspace serialization is simply it's debug value
        serializer.serialize_str(&format!("{:?}", self))
    }
}

impl Serialize for BitDepth
{
    #[allow(clippy::uninlined_format_args)]
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer
    {
        serializer.serialize_str(&format!("{:?}", self))
    }
}

impl Serialize for ColorCharacteristics
{
    #[allow(clippy::uninlined_format_args)]
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer
    {
        serializer.serialize_str(&format!("{:?}", self))
    }
}