use image::ImageFormat;
pub enum SourceType {
Raster(ImageFormat),
Svg,
}
impl SourceType {
pub fn from_mime_type(mime_type: &str) -> Option<Self> {
match ImageFormat::from_mime_type(mime_type) {
Some(format) => Some(Self::Raster(format)),
None => from_custom_mime_type(mime_type),
}
}
}
fn from_custom_mime_type(mime_type: &str) -> Option<SourceType> {
match mime_type {
"image/svg+xml" => Some(SourceType::Svg),
"image/farbfeld" => Some(SourceType::Raster(ImageFormat::Farbfeld)),
_ => None,
}
}