use crate::types::InputStoryContent;
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, EnumString, AsRefStr, IntoStaticStr)]
pub enum InputStoryContentType {
#[strum(serialize = "photo")]
Photo,
#[strum(serialize = "video")]
Video,
}
impl InputStoryContentType {
#[must_use]
pub const fn all() -> [InputStoryContentType; 2usize] {
[InputStoryContentType::Photo, InputStoryContentType::Video]
}
}
impl From<InputStoryContentType> for Box<str> {
fn from(val: InputStoryContentType) -> Self {
Into::<&'static str>::into(val).into()
}
}
impl From<InputStoryContentType> for String {
fn from(val: InputStoryContentType) -> Self {
val.as_ref().to_owned()
}
}
impl<'a> PartialEq<&'a str> for InputStoryContentType {
fn eq(&self, other: &&'a str) -> bool {
self.as_ref() == *other
}
}
impl<'a> From<&'a InputStoryContent> for InputStoryContentType {
fn from(val: &'a InputStoryContent) -> Self {
match val {
InputStoryContent::Photo(_) => InputStoryContentType::Photo,
InputStoryContent::Video(_) => InputStoryContentType::Video,
}
}
}
impl From<InputStoryContent> for InputStoryContentType {
fn from(val: InputStoryContent) -> Self {
InputStoryContentType::from(&val)
}
}