7pub enum ThumbnailError {
9 ImageOpenError(ImageError),
10 ImageSaveError(ImageError),
11 CommandFailed(String),
12 Utf8Error(std::str::Utf8Error),
15 IoError(std::io::Error),
18impl fmt::Display for ThumbnailError {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 ThumbnailError::MissingFileName => write!(f, "Image path is missing a file name"),
22 ThumbnailError::ImageOpenError(e) => write!(f, "Failed to open image: {}", e),
23 ThumbnailError::ImageSaveError(e) => write!(f, "Failed to save thumbnail: {}", e),
24 ThumbnailError::CommandFailed(msg) => write!(f, "ffmpeg command failed: {}", msg),
25 ThumbnailError::Utf8Error(e) => write!(f, "Failed to decode ffmpeg output: {}", e),
26 ThumbnailError::PathConversionError => write!(f, "Failed to convert path to string"),
27 ThumbnailError::SameInputOutputPath => write!(
29 "Cannot write thumbnail to the same path as the original image"
31 ThumbnailError::IoError(e) => write!(f, "I/O error: {}", e),
36impl std::error::Error for ThumbnailError {}
38impl From<ImageError> for ThumbnailError {
39 fn from(err: ImageError) -> Self {
40 ThumbnailError::ImageOpenError(err)
44impl From<std::str::Utf8Error> for ThumbnailError {
45 fn from(err: std::str::Utf8Error) -> Self {
46 ThumbnailError::Utf8Error(err)
50impl From<io::Error> for ThumbnailError {
51 fn from(err: io::Error) -> Self {
52 ThumbnailError::IoError(err)