use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Default)]
pub enum OutputFormat {
#[default]
Text,
Json,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImageOutFormat {
Png,
Jpeg,
Gif,
Webp,
}
impl ImageOutFormat {
#[must_use]
pub fn from_ext(ext: &str) -> Option<Self> {
match ext.to_ascii_lowercase().as_str() {
"png" => Some(ImageOutFormat::Png),
"jpg" | "jpeg" => Some(ImageOutFormat::Jpeg),
"gif" => Some(ImageOutFormat::Gif),
"webp" => Some(ImageOutFormat::Webp),
_ => None,
}
}
#[must_use]
pub fn ext(self) -> &'static str {
match self {
ImageOutFormat::Png => "png",
ImageOutFormat::Jpeg => "jpg",
ImageOutFormat::Gif => "gif",
ImageOutFormat::Webp => "webp",
}
}
#[must_use]
pub fn media_type(self) -> &'static str {
match self {
ImageOutFormat::Png => "image/png",
ImageOutFormat::Jpeg => "image/jpeg",
ImageOutFormat::Gif => "image/gif",
ImageOutFormat::Webp => "image/webp",
}
}
}