use std::fmt::Display;
use wasm_bindgen::prelude::*;
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum MimeType {
TextPlain,
ImagePng,
}
impl Default for MimeType {
fn default() -> Self {
Self::TextPlain
}
}
impl From<MimeType> for JsValue {
fn from(x: MimeType) -> Self {
Self::from(format!("{}", x))
}
}
impl Display for MimeType {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
fmt.write_str(match self {
Self::TextPlain => "text/plain",
Self::ImagePng => "image/png",
})
}
}