wow_world_base/inner/shared/
language_tbc_wrath.rs

1/// Auto generated from the original `wowm` in file [`wow_message_parser/wowm/world/social/social_common_2_4_3.wowm:359`](https://github.com/gtker/wow_messages/tree/main/wow_message_parser/wowm/world/social/social_common_2_4_3.wowm#L359):
2/// ```text
3/// enum Language : u8 {
4///     UNIVERSAL = 0;
5///     ORCISH = 1;
6///     DARNASSIAN = 2;
7///     TAURAHE = 3;
8///     DWARVISH = 6;
9///     COMMON = 7;
10///     DEMONIC = 8;
11///     TITAN = 9;
12///     THALASSIAN = 10;
13///     DRACONIC = 11;
14///     KALIMAG = 12;
15///     GNOMISH = 13;
16///     TROLL = 14;
17///     GUTTERSPEAK = 33;
18///     DRAENEI = 35;
19///     ZOMBIE = 36;
20///     GNOMISH_BINARY = 37;
21///     GOBLIN_BINARY = 38;
22/// }
23/// ```
24#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy, Clone)]
25#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
26pub enum Language {
27    Universal,
28    Orcish,
29    Darnassian,
30    Taurahe,
31    Dwarvish,
32    Common,
33    Demonic,
34    Titan,
35    Thalassian,
36    Draconic,
37    Kalimag,
38    Gnomish,
39    Troll,
40    Gutterspeak,
41    Draenei,
42    Zombie,
43    GnomishBinary,
44    GoblinBinary,
45}
46
47impl Language {
48    pub const fn as_int(&self) -> u8 {
49        match self {
50            Self::Universal => 0x0,
51            Self::Orcish => 0x1,
52            Self::Darnassian => 0x2,
53            Self::Taurahe => 0x3,
54            Self::Dwarvish => 0x6,
55            Self::Common => 0x7,
56            Self::Demonic => 0x8,
57            Self::Titan => 0x9,
58            Self::Thalassian => 0xa,
59            Self::Draconic => 0xb,
60            Self::Kalimag => 0xc,
61            Self::Gnomish => 0xd,
62            Self::Troll => 0xe,
63            Self::Gutterspeak => 0x21,
64            Self::Draenei => 0x23,
65            Self::Zombie => 0x24,
66            Self::GnomishBinary => 0x25,
67            Self::GoblinBinary => 0x26,
68        }
69    }
70
71    pub const fn variants() -> [Self; 18] {
72        [
73            Self::Universal,
74            Self::Orcish,
75            Self::Darnassian,
76            Self::Taurahe,
77            Self::Dwarvish,
78            Self::Common,
79            Self::Demonic,
80            Self::Titan,
81            Self::Thalassian,
82            Self::Draconic,
83            Self::Kalimag,
84            Self::Gnomish,
85            Self::Troll,
86            Self::Gutterspeak,
87            Self::Draenei,
88            Self::Zombie,
89            Self::GnomishBinary,
90            Self::GoblinBinary,
91        ]
92    }
93
94    pub const fn from_int(value: u8) -> Result<Self, crate::errors::EnumError> {
95        match value {
96            0 => Ok(Self::Universal),
97            1 => Ok(Self::Orcish),
98            2 => Ok(Self::Darnassian),
99            3 => Ok(Self::Taurahe),
100            6 => Ok(Self::Dwarvish),
101            7 => Ok(Self::Common),
102            8 => Ok(Self::Demonic),
103            9 => Ok(Self::Titan),
104            10 => Ok(Self::Thalassian),
105            11 => Ok(Self::Draconic),
106            12 => Ok(Self::Kalimag),
107            13 => Ok(Self::Gnomish),
108            14 => Ok(Self::Troll),
109            33 => Ok(Self::Gutterspeak),
110            35 => Ok(Self::Draenei),
111            36 => Ok(Self::Zombie),
112            37 => Ok(Self::GnomishBinary),
113            38 => Ok(Self::GoblinBinary),
114            v => Err(crate::errors::EnumError::new(NAME, v as i128),)
115        }
116    }
117}
118
119#[cfg(feature = "print-testcase")]
120impl Language {
121    pub const fn as_test_case_value(&self) -> &'static str {
122        match self {
123            Self::Universal => "UNIVERSAL",
124            Self::Orcish => "ORCISH",
125            Self::Darnassian => "DARNASSIAN",
126            Self::Taurahe => "TAURAHE",
127            Self::Dwarvish => "DWARVISH",
128            Self::Common => "COMMON",
129            Self::Demonic => "DEMONIC",
130            Self::Titan => "TITAN",
131            Self::Thalassian => "THALASSIAN",
132            Self::Draconic => "DRACONIC",
133            Self::Kalimag => "KALIMAG",
134            Self::Gnomish => "GNOMISH",
135            Self::Troll => "TROLL",
136            Self::Gutterspeak => "GUTTERSPEAK",
137            Self::Draenei => "DRAENEI",
138            Self::Zombie => "ZOMBIE",
139            Self::GnomishBinary => "GNOMISH_BINARY",
140            Self::GoblinBinary => "GOBLIN_BINARY",
141        }
142    }
143
144}
145
146const NAME: &str = "Language";
147
148impl Default for Language {
149    fn default() -> Self {
150        Self::Universal
151    }
152}
153
154impl std::fmt::Display for Language {
155    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
156        match self {
157            Self::Universal => f.write_str("Universal"),
158            Self::Orcish => f.write_str("Orcish"),
159            Self::Darnassian => f.write_str("Darnassian"),
160            Self::Taurahe => f.write_str("Taurahe"),
161            Self::Dwarvish => f.write_str("Dwarvish"),
162            Self::Common => f.write_str("Common"),
163            Self::Demonic => f.write_str("Demonic"),
164            Self::Titan => f.write_str("Titan"),
165            Self::Thalassian => f.write_str("Thalassian"),
166            Self::Draconic => f.write_str("Draconic"),
167            Self::Kalimag => f.write_str("Kalimag"),
168            Self::Gnomish => f.write_str("Gnomish"),
169            Self::Troll => f.write_str("Troll"),
170            Self::Gutterspeak => f.write_str("Gutterspeak"),
171            Self::Draenei => f.write_str("Draenei"),
172            Self::Zombie => f.write_str("Zombie"),
173            Self::GnomishBinary => f.write_str("GnomishBinary"),
174            Self::GoblinBinary => f.write_str("GoblinBinary"),
175        }
176    }
177}
178
179impl TryFrom<u8> for Language {
180    type Error = crate::errors::EnumError;
181    fn try_from(value: u8) -> Result<Self, Self::Error> {
182        Self::from_int(value)
183    }
184}
185
186impl TryFrom<u16> for Language {
187    type Error = crate::errors::EnumError;
188    fn try_from(value: u16) -> Result<Self, Self::Error> {
189        TryInto::<u8>::try_into(value)
190            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
191            .try_into()
192    }
193}
194
195impl TryFrom<u32> for Language {
196    type Error = crate::errors::EnumError;
197    fn try_from(value: u32) -> Result<Self, Self::Error> {
198        TryInto::<u8>::try_into(value)
199            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
200            .try_into()
201    }
202}
203
204impl TryFrom<u64> for Language {
205    type Error = crate::errors::EnumError;
206    fn try_from(value: u64) -> Result<Self, Self::Error> {
207        TryInto::<u8>::try_into(value)
208            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
209            .try_into()
210    }
211}
212
213impl TryFrom<i8> for Language {
214    type Error = crate::errors::EnumError;
215    fn try_from(value: i8) -> Result<Self, Self::Error> {
216        let v = u8::from_le_bytes(value.to_le_bytes());
217        Self::from_int(v)
218    }
219}
220
221impl TryFrom<i16> for Language {
222    type Error = crate::errors::EnumError;
223    fn try_from(value: i16) -> Result<Self, Self::Error> {
224        TryInto::<u8>::try_into(value)
225            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
226            .try_into()
227    }
228}
229
230impl TryFrom<i32> for Language {
231    type Error = crate::errors::EnumError;
232    fn try_from(value: i32) -> Result<Self, Self::Error> {
233        TryInto::<u8>::try_into(value)
234            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
235            .try_into()
236    }
237}
238
239impl TryFrom<i64> for Language {
240    type Error = crate::errors::EnumError;
241    fn try_from(value: i64) -> Result<Self, Self::Error> {
242        TryInto::<u8>::try_into(value)
243            .map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
244            .try_into()
245    }
246}
247
248impl TryFrom<usize> for Language {
249    type Error = crate::errors::EnumError;
250    fn try_from(value: usize) -> Result<Self, Self::Error> {
251        TryInto::<u8>::try_into(value)
252            .map_err(|_| crate::errors::EnumError::new(NAME, value as i128))?
253            .try_into()
254    }
255}
256