use crate::types::Update;
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, EnumString, AsRefStr, IntoStaticStr)]
pub enum UpdateType {
#[strum(serialize = "business_connection")]
BusinessConnection,
#[strum(serialize = "business_message")]
BusinessMessage,
#[strum(serialize = "callback_query")]
CallbackQuery,
#[strum(serialize = "channel_post")]
ChannelPost,
#[strum(serialize = "chat_boost")]
ChatBoost,
#[strum(serialize = "chat_join_request")]
ChatJoinRequest,
#[strum(serialize = "chat_member")]
ChatMember,
#[strum(serialize = "chosen_inline_result")]
ChosenInlineResult,
#[strum(serialize = "deleted_business_messages")]
DeletedBusinessMessages,
#[strum(serialize = "edited_business_message")]
EditedBusinessMessage,
#[strum(serialize = "edited_channel_post")]
EditedChannelPost,
#[strum(serialize = "edited_message")]
EditedMessage,
#[strum(serialize = "inline_query")]
InlineQuery,
#[strum(serialize = "managed_bot")]
ManagedBot,
#[strum(serialize = "message")]
Message,
#[strum(serialize = "message_reaction")]
MessageReaction,
#[strum(serialize = "message_reaction_count")]
MessageReactionCount,
#[strum(serialize = "my_chat_member")]
MyChatMember,
#[strum(serialize = "poll")]
Poll,
#[strum(serialize = "poll_answer")]
PollAnswer,
#[strum(serialize = "pre_checkout_query")]
PreCheckoutQuery,
#[strum(serialize = "purchased_paid_media")]
PurchasedPaidMedia,
#[strum(serialize = "removed_chat_boost")]
RemovedChatBoost,
#[strum(serialize = "shipping_query")]
ShippingQuery,
}
impl UpdateType {
#[must_use]
pub const fn all() -> [UpdateType; 24usize] {
[
UpdateType::BusinessConnection,
UpdateType::BusinessMessage,
UpdateType::CallbackQuery,
UpdateType::ChannelPost,
UpdateType::ChatBoost,
UpdateType::ChatJoinRequest,
UpdateType::ChatMember,
UpdateType::ChosenInlineResult,
UpdateType::DeletedBusinessMessages,
UpdateType::EditedBusinessMessage,
UpdateType::EditedChannelPost,
UpdateType::EditedMessage,
UpdateType::InlineQuery,
UpdateType::ManagedBot,
UpdateType::Message,
UpdateType::MessageReaction,
UpdateType::MessageReactionCount,
UpdateType::MyChatMember,
UpdateType::Poll,
UpdateType::PollAnswer,
UpdateType::PreCheckoutQuery,
UpdateType::PurchasedPaidMedia,
UpdateType::RemovedChatBoost,
UpdateType::ShippingQuery,
]
}
}
impl From<UpdateType> for Box<str> {
fn from(val: UpdateType) -> Self {
Into::<&'static str>::into(val).into()
}
}
impl From<UpdateType> for String {
fn from(val: UpdateType) -> Self {
val.as_ref().to_owned()
}
}
impl<'a> PartialEq<&'a str> for UpdateType {
fn eq(&self, other: &&'a str) -> bool {
self.as_ref() == *other
}
}
impl<'a> From<&'a Update> for UpdateType {
fn from(val: &'a Update) -> Self {
match val {
Update::BusinessConnection(_) => UpdateType::BusinessConnection,
Update::BusinessMessage(_) => UpdateType::BusinessMessage,
Update::CallbackQuery(_) => UpdateType::CallbackQuery,
Update::ChannelPost(_) => UpdateType::ChannelPost,
Update::ChatBoost(_) => UpdateType::ChatBoost,
Update::ChatJoinRequest(_) => UpdateType::ChatJoinRequest,
Update::ChatMember(_) => UpdateType::ChatMember,
Update::ChosenInlineResult(_) => UpdateType::ChosenInlineResult,
Update::DeletedBusinessMessages(_) => UpdateType::DeletedBusinessMessages,
Update::EditedBusinessMessage(_) => UpdateType::EditedBusinessMessage,
Update::EditedChannelPost(_) => UpdateType::EditedChannelPost,
Update::EditedMessage(_) => UpdateType::EditedMessage,
Update::InlineQuery(_) => UpdateType::InlineQuery,
Update::ManagedBot(_) => UpdateType::ManagedBot,
Update::Message(_) => UpdateType::Message,
Update::MessageReaction(_) => UpdateType::MessageReaction,
Update::MessageReactionCount(_) => UpdateType::MessageReactionCount,
Update::MyChatMember(_) => UpdateType::MyChatMember,
Update::Poll(_) => UpdateType::Poll,
Update::PollAnswer(_) => UpdateType::PollAnswer,
Update::PreCheckoutQuery(_) => UpdateType::PreCheckoutQuery,
Update::PurchasedPaidMedia(_) => UpdateType::PurchasedPaidMedia,
Update::RemovedChatBoost(_) => UpdateType::RemovedChatBoost,
Update::ShippingQuery(_) => UpdateType::ShippingQuery,
}
}
}
impl From<Update> for UpdateType {
fn from(val: Update) -> Self {
UpdateType::from(&val)
}
}