use std::fmt::{Display, Formatter, Result}; use std::path::PathBuf; #[derive(Debug)] pub enum ScanError { /// Something went wrong while trying to read the given file. File(PathBuf), /// Failed to determine the mimetype of the given file. Mime(PathBuf), } impl Display for ScanError { fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!( f, "Couldn't {} file: {}", match self { Self::File(_) => "read", Self::Mime(_) => "determine mime type of", }, match self { Self::File(f) | Self::Mime(f) => f.to_string_lossy(), } ) } }