#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OutputFormat {
Png,
Svg,
Pdf,
}
impl OutputFormat {
pub fn from_str(s: &str) -> Option<Self> {
match s.to_lowercase().as_str() {
"png" => Some(OutputFormat::Png),
"svg" => Some(OutputFormat::Svg),
"pdf" => Some(OutputFormat::Pdf),
_ => None,
}
}
pub fn extension(&self) -> &'static str {
match self {
OutputFormat::Png => "png",
OutputFormat::Svg => "svg",
OutputFormat::Pdf => "pdf",
}
}
}