wow_world_base/inner/vanilla/
party_result.rs

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