wow_world_base/inner/wrath/
calendar_status.rs

1/// Auto generated from the original `wowm` in file [`wow_message_parser/wowm/world/calendar/cmsg_calendar_event_rsvp.wowm:1`](https://github.com/gtker/wow_messages/tree/main/wow_message_parser/wowm/world/calendar/cmsg_calendar_event_rsvp.wowm#L1):
2/// ```text
3/// enum CalendarStatus : u8 {
4///     INVITED = 0;
5///     ACCEPTED = 1;
6///     DECLINED = 2;
7///     CONFIRMED = 3;
8///     OUT = 4;
9///     STANDBY = 5;
10///     SIGNED_UP = 6;
11///     NOT_SIGNED_UP = 7;
12///     TENTATIVE = 8;
13///     REMOVED = 9;
14/// }
15/// ```
16#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy, Clone)]
17#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
18pub enum CalendarStatus {
19    Invited,
20    Accepted,
21    Declined,
22    Confirmed,
23    Out,
24    Standby,
25    SignedUp,
26    NotSignedUp,
27    Tentative,
28    Removed,
29}
30
31impl CalendarStatus {
32    pub const fn as_int(&self) -> u8 {
33        match self {
34            Self::Invited => 0x0,
35            Self::Accepted => 0x1,
36            Self::Declined => 0x2,
37            Self::Confirmed => 0x3,
38            Self::Out => 0x4,
39            Self::Standby => 0x5,
40            Self::SignedUp => 0x6,
41            Self::NotSignedUp => 0x7,
42            Self::Tentative => 0x8,
43            Self::Removed => 0x9,
44        }
45    }
46
47    pub const fn variants() -> [Self; 10] {
48        [
49            Self::Invited,
50            Self::Accepted,
51            Self::Declined,
52            Self::Confirmed,
53            Self::Out,
54            Self::Standby,
55            Self::SignedUp,
56            Self::NotSignedUp,
57            Self::Tentative,
58            Self::Removed,
59        ]
60    }
61
62    pub const fn from_int(value: u8) -> Result<Self, crate::errors::EnumError> {
63        match value {
64            0 => Ok(Self::Invited),
65            1 => Ok(Self::Accepted),
66            2 => Ok(Self::Declined),
67            3 => Ok(Self::Confirmed),
68            4 => Ok(Self::Out),
69            5 => Ok(Self::Standby),
70            6 => Ok(Self::SignedUp),
71            7 => Ok(Self::NotSignedUp),
72            8 => Ok(Self::Tentative),
73            9 => Ok(Self::Removed),
74            v => Err(crate::errors::EnumError::new(NAME, v as i128),)
75        }
76    }
77}
78
79#[cfg(feature = "print-testcase")]
80impl CalendarStatus {
81    pub const fn as_test_case_value(&self) -> &'static str {
82        match self {
83            Self::Invited => "INVITED",
84            Self::Accepted => "ACCEPTED",
85            Self::Declined => "DECLINED",
86            Self::Confirmed => "CONFIRMED",
87            Self::Out => "OUT",
88            Self::Standby => "STANDBY",
89            Self::SignedUp => "SIGNED_UP",
90            Self::NotSignedUp => "NOT_SIGNED_UP",
91            Self::Tentative => "TENTATIVE",
92            Self::Removed => "REMOVED",
93        }
94    }
95
96}
97
98const NAME: &str = "CalendarStatus";
99
100impl Default for CalendarStatus {
101    fn default() -> Self {
102        Self::Invited
103    }
104}
105
106impl std::fmt::Display for CalendarStatus {
107    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108        match self {
109            Self::Invited => f.write_str("Invited"),
110            Self::Accepted => f.write_str("Accepted"),
111            Self::Declined => f.write_str("Declined"),
112            Self::Confirmed => f.write_str("Confirmed"),
113            Self::Out => f.write_str("Out"),
114            Self::Standby => f.write_str("Standby"),
115            Self::SignedUp => f.write_str("SignedUp"),
116            Self::NotSignedUp => f.write_str("NotSignedUp"),
117            Self::Tentative => f.write_str("Tentative"),
118            Self::Removed => f.write_str("Removed"),
119        }
120    }
121}
122
123impl TryFrom<u8> for CalendarStatus {
124    type Error = crate::errors::EnumError;
125    fn try_from(value: u8) -> Result<Self, Self::Error> {
126        Self::from_int(value)
127    }
128}
129
130impl TryFrom<u16> for CalendarStatus {
131    type Error = crate::errors::EnumError;
132    fn try_from(value: u16) -> Result<Self, Self::Error> {
133        TryInto::<u8>::try_into(value)
134            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
135            .try_into()
136    }
137}
138
139impl TryFrom<u32> for CalendarStatus {
140    type Error = crate::errors::EnumError;
141    fn try_from(value: u32) -> Result<Self, Self::Error> {
142        TryInto::<u8>::try_into(value)
143            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
144            .try_into()
145    }
146}
147
148impl TryFrom<u64> for CalendarStatus {
149    type Error = crate::errors::EnumError;
150    fn try_from(value: u64) -> Result<Self, Self::Error> {
151        TryInto::<u8>::try_into(value)
152            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
153            .try_into()
154    }
155}
156
157impl TryFrom<i8> for CalendarStatus {
158    type Error = crate::errors::EnumError;
159    fn try_from(value: i8) -> Result<Self, Self::Error> {
160        let v = u8::from_le_bytes(value.to_le_bytes());
161        Self::from_int(v)
162    }
163}
164
165impl TryFrom<i16> for CalendarStatus {
166    type Error = crate::errors::EnumError;
167    fn try_from(value: i16) -> Result<Self, Self::Error> {
168        TryInto::<u8>::try_into(value)
169            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
170            .try_into()
171    }
172}
173
174impl TryFrom<i32> for CalendarStatus {
175    type Error = crate::errors::EnumError;
176    fn try_from(value: i32) -> Result<Self, Self::Error> {
177        TryInto::<u8>::try_into(value)
178            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
179            .try_into()
180    }
181}
182
183impl TryFrom<i64> for CalendarStatus {
184    type Error = crate::errors::EnumError;
185    fn try_from(value: i64) -> Result<Self, Self::Error> {
186        TryInto::<u8>::try_into(value)
187            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
188            .try_into()
189    }
190}
191
192impl TryFrom<usize> for CalendarStatus {
193    type Error = crate::errors::EnumError;
194    fn try_from(value: usize) -> Result<Self, Self::Error> {
195        TryInto::<u8>::try_into(value)
196            .map_err(|_| crate::errors::EnumError::new(NAME, value as i128))?
197            .try_into()
198    }
199}
200