telers 1.0.0-beta.7

An asynchronous framework for Telegram Bot API written in Rust
Documentation
use crate::types::Sticker;
use serde::{Deserialize, Serialize};
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
/// This object represents a sticker.
/// Currently, it can be one of
/// - [`crate::types::StickerCustomEmoji`]
/// - [`crate::types::StickerMask`]
/// - [`crate::types::StickerRegular`]
/// # Documentation
/// <https://core.telegram.org/bots/api#sticker>
#[derive(
    Debug,
    Display,
    Clone,
    Copy,
    PartialEq,
    Eq,
    Hash,
    EnumString,
    AsRefStr,
    IntoStaticStr,
    Deserialize,
    Serialize,
)]
pub enum StickerType {
    #[strum(serialize = "regular")]
    Regular,
    #[strum(serialize = "mask")]
    Mask,
    #[strum(serialize = "custom_emoji")]
    CustomEmoji,
    #[strum(serialize = "unknown")]
    Unknown,
}
impl StickerType {
    #[must_use]
    pub const fn all() -> [StickerType; 4usize] {
        [
            StickerType::Regular,
            StickerType::Mask,
            StickerType::CustomEmoji,
            StickerType::Unknown,
        ]
    }
}
impl From<StickerType> for Box<str> {
    fn from(val: StickerType) -> Self {
        Into::<&'static str>::into(val).into()
    }
}
impl From<StickerType> for String {
    fn from(val: StickerType) -> Self {
        val.as_ref().to_owned()
    }
}
impl<'a> PartialEq<&'a str> for StickerType {
    fn eq(&self, other: &&'a str) -> bool {
        self.as_ref() == *other
    }
}
impl<'a> From<&'a Sticker> for StickerType {
    fn from(val: &'a Sticker) -> Self {
        match val {
            Sticker::Regular(_) => StickerType::Regular,
            Sticker::Mask(_) => StickerType::Mask,
            Sticker::CustomEmoji(_) => StickerType::CustomEmoji,
            Sticker::Unknown(_) => StickerType::Unknown,
        }
    }
}
impl From<Sticker> for StickerType {
    fn from(val: Sticker) -> Self {
        StickerType::from(&val)
    }
}