fif/src/findings.rs

23 lines
586 B
Rust

use std::path::PathBuf;
use mime_guess::Mime;
use smartstring::alias::*;
use crate::inspectors::mime_extension_lookup;
/// Information about a scanned file.
pub struct Findings {
/// The location of the scanned file.
pub file: PathBuf, // TODO: replace with Path???? <'a> and all that
/// Whether or not the file's extension is valid for its mimetype.
pub valid: bool,
/// The file's mimetype.
pub mime: Mime,
}
impl Findings {
pub fn recommended_extension(&self) -> Option<String> {
mime_extension_lookup(self.mime.clone()).map(|extensions| extensions[0].to_owned())
}
}