#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum ChatNotify {
JoinedNotice,
LeftNotice,
YouJoinedNotice,
YouLeftNotice,
WrongPasswordNotice,
NotMemberNotice,
NotModeratorNotice,
PasswordChangedNotice,
OwnerChangedNotice,
PlayerNotFoundNotice,
NotOwnerNotice,
ChannelOwnerNotice,
ModeChangeNotice,
AnnouncementsOnNotice,
AnnouncementsOffNotice,
ModerationOnNotice,
ModerationOffNotice,
MutedNotice,
PlayerKickedNotice,
BannedNotice,
PlayerBannedNotice,
PlayerUnbannedNotice,
PlayerNotBannedNotice,
PlayerAlreadyMemberNotice,
InviteNotice,
InviteWrongFactionNotice,
WrongFactionNotice,
InvalidNameNotice,
NotModeratedNotice,
PlayerInvitedNotice,
PlayerInviteBannedNotice,
ThrottledNotice,
NotInAreaNotice,
NotInLfgNotice,
VoiceOnNotice,
VoiceOffNotice,
}
impl ChatNotify {
pub const fn as_int(&self) -> u8 {
match self {
Self::JoinedNotice => 0x0,
Self::LeftNotice => 0x1,
Self::YouJoinedNotice => 0x2,
Self::YouLeftNotice => 0x3,
Self::WrongPasswordNotice => 0x4,
Self::NotMemberNotice => 0x5,
Self::NotModeratorNotice => 0x6,
Self::PasswordChangedNotice => 0x7,
Self::OwnerChangedNotice => 0x8,
Self::PlayerNotFoundNotice => 0x9,
Self::NotOwnerNotice => 0xa,
Self::ChannelOwnerNotice => 0xb,
Self::ModeChangeNotice => 0xc,
Self::AnnouncementsOnNotice => 0xd,
Self::AnnouncementsOffNotice => 0xe,
Self::ModerationOnNotice => 0xf,
Self::ModerationOffNotice => 0x10,
Self::MutedNotice => 0x11,
Self::PlayerKickedNotice => 0x12,
Self::BannedNotice => 0x13,
Self::PlayerBannedNotice => 0x14,
Self::PlayerUnbannedNotice => 0x15,
Self::PlayerNotBannedNotice => 0x16,
Self::PlayerAlreadyMemberNotice => 0x17,
Self::InviteNotice => 0x18,
Self::InviteWrongFactionNotice => 0x19,
Self::WrongFactionNotice => 0x1a,
Self::InvalidNameNotice => 0x1b,
Self::NotModeratedNotice => 0x1c,
Self::PlayerInvitedNotice => 0x1d,
Self::PlayerInviteBannedNotice => 0x1e,
Self::ThrottledNotice => 0x1f,
Self::NotInAreaNotice => 0x20,
Self::NotInLfgNotice => 0x21,
Self::VoiceOnNotice => 0x22,
Self::VoiceOffNotice => 0x23,
}
}
pub const fn variants() -> [Self; 36] {
[
Self::JoinedNotice,
Self::LeftNotice,
Self::YouJoinedNotice,
Self::YouLeftNotice,
Self::WrongPasswordNotice,
Self::NotMemberNotice,
Self::NotModeratorNotice,
Self::PasswordChangedNotice,
Self::OwnerChangedNotice,
Self::PlayerNotFoundNotice,
Self::NotOwnerNotice,
Self::ChannelOwnerNotice,
Self::ModeChangeNotice,
Self::AnnouncementsOnNotice,
Self::AnnouncementsOffNotice,
Self::ModerationOnNotice,
Self::ModerationOffNotice,
Self::MutedNotice,
Self::PlayerKickedNotice,
Self::BannedNotice,
Self::PlayerBannedNotice,
Self::PlayerUnbannedNotice,
Self::PlayerNotBannedNotice,
Self::PlayerAlreadyMemberNotice,
Self::InviteNotice,
Self::InviteWrongFactionNotice,
Self::WrongFactionNotice,
Self::InvalidNameNotice,
Self::NotModeratedNotice,
Self::PlayerInvitedNotice,
Self::PlayerInviteBannedNotice,
Self::ThrottledNotice,
Self::NotInAreaNotice,
Self::NotInLfgNotice,
Self::VoiceOnNotice,
Self::VoiceOffNotice,
]
}
pub const fn from_int(value: u8) -> Result<Self, crate::errors::EnumError> {
match value {
0 => Ok(Self::JoinedNotice),
1 => Ok(Self::LeftNotice),
2 => Ok(Self::YouJoinedNotice),
3 => Ok(Self::YouLeftNotice),
4 => Ok(Self::WrongPasswordNotice),
5 => Ok(Self::NotMemberNotice),
6 => Ok(Self::NotModeratorNotice),
7 => Ok(Self::PasswordChangedNotice),
8 => Ok(Self::OwnerChangedNotice),
9 => Ok(Self::PlayerNotFoundNotice),
10 => Ok(Self::NotOwnerNotice),
11 => Ok(Self::ChannelOwnerNotice),
12 => Ok(Self::ModeChangeNotice),
13 => Ok(Self::AnnouncementsOnNotice),
14 => Ok(Self::AnnouncementsOffNotice),
15 => Ok(Self::ModerationOnNotice),
16 => Ok(Self::ModerationOffNotice),
17 => Ok(Self::MutedNotice),
18 => Ok(Self::PlayerKickedNotice),
19 => Ok(Self::BannedNotice),
20 => Ok(Self::PlayerBannedNotice),
21 => Ok(Self::PlayerUnbannedNotice),
22 => Ok(Self::PlayerNotBannedNotice),
23 => Ok(Self::PlayerAlreadyMemberNotice),
24 => Ok(Self::InviteNotice),
25 => Ok(Self::InviteWrongFactionNotice),
26 => Ok(Self::WrongFactionNotice),
27 => Ok(Self::InvalidNameNotice),
28 => Ok(Self::NotModeratedNotice),
29 => Ok(Self::PlayerInvitedNotice),
30 => Ok(Self::PlayerInviteBannedNotice),
31 => Ok(Self::ThrottledNotice),
32 => Ok(Self::NotInAreaNotice),
33 => Ok(Self::NotInLfgNotice),
34 => Ok(Self::VoiceOnNotice),
35 => Ok(Self::VoiceOffNotice),
v => Err(crate::errors::EnumError::new(NAME, v as i128),)
}
}
}
#[cfg(feature = "print-testcase")]
impl ChatNotify {
pub const fn as_test_case_value(&self) -> &'static str {
match self {
Self::JoinedNotice => "JOINED_NOTICE",
Self::LeftNotice => "LEFT_NOTICE",
Self::YouJoinedNotice => "YOU_JOINED_NOTICE",
Self::YouLeftNotice => "YOU_LEFT_NOTICE",
Self::WrongPasswordNotice => "WRONG_PASSWORD_NOTICE",
Self::NotMemberNotice => "NOT_MEMBER_NOTICE",
Self::NotModeratorNotice => "NOT_MODERATOR_NOTICE",
Self::PasswordChangedNotice => "PASSWORD_CHANGED_NOTICE",
Self::OwnerChangedNotice => "OWNER_CHANGED_NOTICE",
Self::PlayerNotFoundNotice => "PLAYER_NOT_FOUND_NOTICE",
Self::NotOwnerNotice => "NOT_OWNER_NOTICE",
Self::ChannelOwnerNotice => "CHANNEL_OWNER_NOTICE",
Self::ModeChangeNotice => "MODE_CHANGE_NOTICE",
Self::AnnouncementsOnNotice => "ANNOUNCEMENTS_ON_NOTICE",
Self::AnnouncementsOffNotice => "ANNOUNCEMENTS_OFF_NOTICE",
Self::ModerationOnNotice => "MODERATION_ON_NOTICE",
Self::ModerationOffNotice => "MODERATION_OFF_NOTICE",
Self::MutedNotice => "MUTED_NOTICE",
Self::PlayerKickedNotice => "PLAYER_KICKED_NOTICE",
Self::BannedNotice => "BANNED_NOTICE",
Self::PlayerBannedNotice => "PLAYER_BANNED_NOTICE",
Self::PlayerUnbannedNotice => "PLAYER_UNBANNED_NOTICE",
Self::PlayerNotBannedNotice => "PLAYER_NOT_BANNED_NOTICE",
Self::PlayerAlreadyMemberNotice => "PLAYER_ALREADY_MEMBER_NOTICE",
Self::InviteNotice => "INVITE_NOTICE",
Self::InviteWrongFactionNotice => "INVITE_WRONG_FACTION_NOTICE",
Self::WrongFactionNotice => "WRONG_FACTION_NOTICE",
Self::InvalidNameNotice => "INVALID_NAME_NOTICE",
Self::NotModeratedNotice => "NOT_MODERATED_NOTICE",
Self::PlayerInvitedNotice => "PLAYER_INVITED_NOTICE",
Self::PlayerInviteBannedNotice => "PLAYER_INVITE_BANNED_NOTICE",
Self::ThrottledNotice => "THROTTLED_NOTICE",
Self::NotInAreaNotice => "NOT_IN_AREA_NOTICE",
Self::NotInLfgNotice => "NOT_IN_LFG_NOTICE",
Self::VoiceOnNotice => "VOICE_ON_NOTICE",
Self::VoiceOffNotice => "VOICE_OFF_NOTICE",
}
}
}
const NAME: &str = "ChatNotify";
impl Default for ChatNotify {
fn default() -> Self {
Self::JoinedNotice
}
}
impl std::fmt::Display for ChatNotify {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::JoinedNotice => f.write_str("JoinedNotice"),
Self::LeftNotice => f.write_str("LeftNotice"),
Self::YouJoinedNotice => f.write_str("YouJoinedNotice"),
Self::YouLeftNotice => f.write_str("YouLeftNotice"),
Self::WrongPasswordNotice => f.write_str("WrongPasswordNotice"),
Self::NotMemberNotice => f.write_str("NotMemberNotice"),
Self::NotModeratorNotice => f.write_str("NotModeratorNotice"),
Self::PasswordChangedNotice => f.write_str("PasswordChangedNotice"),
Self::OwnerChangedNotice => f.write_str("OwnerChangedNotice"),
Self::PlayerNotFoundNotice => f.write_str("PlayerNotFoundNotice"),
Self::NotOwnerNotice => f.write_str("NotOwnerNotice"),
Self::ChannelOwnerNotice => f.write_str("ChannelOwnerNotice"),
Self::ModeChangeNotice => f.write_str("ModeChangeNotice"),
Self::AnnouncementsOnNotice => f.write_str("AnnouncementsOnNotice"),
Self::AnnouncementsOffNotice => f.write_str("AnnouncementsOffNotice"),
Self::ModerationOnNotice => f.write_str("ModerationOnNotice"),
Self::ModerationOffNotice => f.write_str("ModerationOffNotice"),
Self::MutedNotice => f.write_str("MutedNotice"),
Self::PlayerKickedNotice => f.write_str("PlayerKickedNotice"),
Self::BannedNotice => f.write_str("BannedNotice"),
Self::PlayerBannedNotice => f.write_str("PlayerBannedNotice"),
Self::PlayerUnbannedNotice => f.write_str("PlayerUnbannedNotice"),
Self::PlayerNotBannedNotice => f.write_str("PlayerNotBannedNotice"),
Self::PlayerAlreadyMemberNotice => f.write_str("PlayerAlreadyMemberNotice"),
Self::InviteNotice => f.write_str("InviteNotice"),
Self::InviteWrongFactionNotice => f.write_str("InviteWrongFactionNotice"),
Self::WrongFactionNotice => f.write_str("WrongFactionNotice"),
Self::InvalidNameNotice => f.write_str("InvalidNameNotice"),
Self::NotModeratedNotice => f.write_str("NotModeratedNotice"),
Self::PlayerInvitedNotice => f.write_str("PlayerInvitedNotice"),
Self::PlayerInviteBannedNotice => f.write_str("PlayerInviteBannedNotice"),
Self::ThrottledNotice => f.write_str("ThrottledNotice"),
Self::NotInAreaNotice => f.write_str("NotInAreaNotice"),
Self::NotInLfgNotice => f.write_str("NotInLfgNotice"),
Self::VoiceOnNotice => f.write_str("VoiceOnNotice"),
Self::VoiceOffNotice => f.write_str("VoiceOffNotice"),
}
}
}
impl TryFrom<u8> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::from_int(value)
}
}
impl TryFrom<u16> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: u16) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<u32> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: u32) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<u64> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: u64) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<i8> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: i8) -> Result<Self, Self::Error> {
let v = u8::from_le_bytes(value.to_le_bytes());
Self::from_int(v)
}
}
impl TryFrom<i16> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: i16) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<i32> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: i32) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<i64> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: i64) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value.into()))?
.try_into()
}
}
impl TryFrom<usize> for ChatNotify {
type Error = crate::errors::EnumError;
fn try_from(value: usize) -> Result<Self, Self::Error> {
TryInto::<u8>::try_into(value)
.map_err(|_| crate::errors::EnumError::new(NAME, value as i128))?
.try_into()
}
}