fif/src/scan_error.rs
Lynnesbian e3af10cf5b
All checks were successful
continuous-integration/drone/push Build is passing
replaced some pathbufs with paths, made it actually compile and work 0uo
2021-03-12 03:26:35 +10:00

26 lines
581 B
Rust

use std::fmt::{Display, Formatter, Result};
use std::path::Path;
#[derive(Debug)]
pub enum ScanError<'a> {
/// Something went wrong while trying to read the given file.
File(&'a Path),
/// Failed to determine the mimetype of the given file.
Mime(&'a Path),
}
impl<'a> Display for ScanError<'a> {
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(),
}
)
}
}