use std::str::FromStr;
use std::string::ParseError;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone, Hash, PartialEq, Eq, Copy)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
#[cfg_attr(feature = "specta", derive(specta::Type))]
#[cfg_attr(feature = "async-graphql", derive(async_graphql::Enum))]
pub enum LegacyMappingType {
Chapter,
Group,
Manga,
Tag,
}
impl From<&str> for LegacyMappingType {
fn from(value: &str) -> Self {
match value.to_lowercase().as_str() {
"chapter" => Self::Chapter,
"group" => Self::Group,
"manga" => Self::Manga,
"tag" => Self::Tag,
_ => Self::Manga,
}
}
}
impl FromStr for LegacyMappingType {
type Err = ParseError;
fn from_str(value: &str) -> Result<Self, ParseError> {
Ok(Self::from(value))
}
}