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
use serde::{Deserialize, Serialize};

#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum Category {
    #[serde(rename = "DIGITAL_GOODS")]
    DigitalGoods,
    #[serde(rename = "PHYSICAL_GOODS")]
    PhysicalGoods,
    #[serde(rename = "DONATION")]
    Donation,
}

impl Category {
    pub fn as_str(self) -> &'static str {
        match self {
            Category::DigitalGoods => "DIGITAL_GOODS",
            Category::PhysicalGoods => "PHYSICAL_GOODS",
            Category::Donation => "DONATION",
        }
    }
}

impl AsRef<str> for Category {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for Category {
    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(formatter)
    }
}