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