simple_file_rotation/
error.rs

1use std::path::PathBuf;
2
3pub type Result<T> = std::result::Result<T, FileRotationError>;
4
5#[non_exhaustive]
6#[derive(Debug)]
7pub enum FileRotationError {
8    NotAFile(PathBuf),
9    Io(std::io::Error),
10}
11
12impl std::error::Error for FileRotationError {}
13
14impl std::fmt::Display for FileRotationError {
15    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16        match self {
17            FileRotationError::Io(err) => {
18                write!(f, "FileRotation io error: {err}")
19            }
20            FileRotationError::NotAFile(path) => {
21                write!(f, "path {path:?} is not a file")
22            }
23        }
24    }
25}
26
27impl From<std::io::Error> for FileRotationError {
28    fn from(err: std::io::Error) -> Self {
29        Self::Io(err)
30    }
31}