1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
pub type Result<T> = std::result::Result<T, Error>;
#[allow(clippy::large_enum_variant)]
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("ZFS error: {0:?}")]
ZFS(String),
#[error("Snapshot Error: {0:?}")]
Snapshot(String),
#[error("Pool `{0}` does not exist")]
PoolNotFound(std::path::PathBuf),
#[error("Failed to clone filesystem")]
Clone,
#[error("FileSystem Error: {0:?}")]
FileSystem(#[from] FileSystemError),
#[error("Command Error: {0:?}")]
Command(#[from] CommandError),
#[error("Failed to parse Command output: {0:?}")]
Utf8(#[from] std::string::FromUtf8Error),
#[error("Config Error: {0:?}")]
Config(#[from] figment::Error),
#[error(transparent)]
Builder(#[from] crate::file_system::FileSystemBuilderError),
}
#[derive(thiserror::Error, Debug)]
pub enum CommandError {
#[error("Command process failed to execute: {0:?}")]
Execution(#[from] std::io::Error),
#[error("Command process exited with status code: {0:?}")]
ExitStatus(i32),
#[error("Failed to parse command output: {0:?}")]
Parsing(#[from] std::string::FromUtf8Error),
}
impl From<i32> for CommandError {
fn from(i: i32) -> Self {
Self::ExitStatus(i)
}
}
#[derive(thiserror::Error, Debug)]
pub enum FileSystemError {
#[error("Filesystem does not exist")]
NotFound,
#[error("Filesystem exist but is not mounted")]
NotMounted,
#[error("Failed to create filesystem: Status code: {0:?}")]
Creating(i32),
#[error("Failed to clone filesystem: Status code: {0:?}")]
Cloning(i32),
#[error("Failed to destroy filesystem: Status code: {0:?}")]
Destroying(i32),
#[error("Failed to mount filesystem: Status code: {0:?}")]
Mounting(i32),
#[error("Failed to unmount filesystem: Status code: {0:?}")]
Unmounting(i32),
#[error("Failed to parse filesystem from UTF-8: {0:?}")]
Parsing(#[from] std::string::FromUtf8Error),
#[error("{0}")]
Other(String),
}
|