fif/src/findings.rs

24 lines
591 B
Rust
Raw Normal View History

use std::path::Path;
2021-02-18 09:48:38 +00:00
use mime_guess::Mime;
2021-02-18 09:48:38 +00:00
use crate::inspectors::mime_extension_lookup;
2021-04-20 05:20:10 +00:00
use crate::string_type::String;
2021-02-18 09:48:38 +00:00
/// Information about a scanned file.
#[derive(Ord, PartialOrd, Eq, PartialEq)]
pub struct Findings<'a> {
/// The location of the scanned file.
pub file: &'a Path,
/// Whether or not the file's extension is valid for its mimetype.
pub valid: bool,
/// The file's mimetype.
pub mime: Mime,
}
impl<'a> Findings<'a> {
pub fn recommended_extension(&self) -> Option<String> {
2021-04-28 13:19:04 +00:00
mime_extension_lookup(self.mime.clone()).map(|extensions| extensions[0].clone())
}
}