#[derive(Debug, Clone, Copy)]
pub enum OutputImageType {
Png,
Gif,
}
const IMG_TYPE_PNG: &str = ".png";
const IMG_TYPE_GIF: &str = ".gif";
pub const IMG_TYPES_ARRAY: &[&str] = &[IMG_TYPE_PNG, IMG_TYPE_GIF];
impl OutputImageType {
fn from_str(output_image_type_str: &str) -> Option<Self> {
match output_image_type_str {
IMG_TYPE_PNG => Some(OutputImageType::Png),
IMG_TYPE_GIF => Some(OutputImageType::Gif),
_ => None,
}
}
pub fn from_file_name(file_name: &str) -> Option<Self> {
let file_extension_start_idx = file_name.rfind(".");
match file_extension_start_idx {
Some(file_extension_start_idx) => {
Self::from_str(&file_name[file_extension_start_idx..])
}
None => None,
}
}
pub fn as_file_extension(&self) -> &'static str {
match *self {
OutputImageType::Png => IMG_TYPE_PNG,
OutputImageType::Gif => IMG_TYPE_GIF,
}
}
}
#[derive(Debug, Clone)]
pub enum ImageBatchType {
Single,
Batch {
final_index: u32,
},
}