1use std::path::PathBuf;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, Error)]
7pub enum Error {
8 #[error(transparent)]
9 Io(#[from] std::io::Error),
10
11 #[error("path not found: {}", .0.display())]
12 NotFound(PathBuf),
13
14 #[error("resource modified externally: {}", .0.display())]
15 ModifiedExternally(PathBuf),
16
17 #[error("atomic write failed at {}: {}", .path.display(), .source)]
18 Write {
19 path: PathBuf,
20 source: std::io::Error,
21 },
22
23 #[error("atomic read failed at {}: {}", .path.display(), .source)]
24 Read {
25 path: PathBuf,
26 source: std::io::Error,
27 },
28
29 #[error("directory replace failed at {}: {}", .path.display(), .source)]
30 ReplaceDir {
31 path: PathBuf,
32 source: std::io::Error,
33 },
34
35 #[error("retry limit exceeded after {0} attempts")]
36 RetryLimitExceeded(u32),
37
38 #[error("invalid input: {0}")]
39 InvalidInput(String),
40
41 #[error("cross-device hardlink not supported")]
42 CrossDeviceHardlink,
43
44 #[error("operation failed")]
45 Failed,
46}