#[derive(Clone, Copy, PartialEq, Eq)]
pub enum KnownFmt {
Json,
Toml,
Png,
Ogg,
Nbt,
Cfg,
Obj,
Mtl,
Fsh,
Vsh,
Js,
Zs,
Jar,
Mf,
Other([u8; 3])
}
impl KnownFmt {
#[must_use]
pub fn by_extension(ftype: &str) -> Option<Self> {
Some(match ftype.to_ascii_lowercase().as_str() {
"json" | "mcmeta" => Self::Json,
"toml" => Self::Toml,
"png" => Self::Png,
"ogg" => Self::Ogg,
"nbt" | "blueprint" => Self::Nbt,
"cfg" => Self::Cfg,
"obj" => Self::Obj,
"mtl" => Self::Mtl,
"fsh" => Self::Fsh,
"vsh" => Self::Vsh,
"js" => Self::Js,
"zs" => Self::Zs,
"jar" => Self::Jar,
"mf" => Self::Mf,
x => match x.as_bytes() {
[a] => Self::Other([*a, 0, 0]),
[a, b] => Self::Other([*a, *b, 0]),
[a, b, c] => Self::Other([*a, *b, *c]),
_ => return None
}
})
}
}