aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
diff options
context:
space:
mode:
authorIgor Tolmachov <me@igorek.dev>2023-08-17 15:34:47 +0900
committerIgor Tolmachev <me@igorek.dev>2024-06-23 15:34:32 +0900
commitd8be93a740e8cc8103c4f9e260a62244eba1a6a4 (patch)
treeacc3b3b7f86fa3e2e4e8656d554efa62a24aa3f7 /src/result.rs
parent22dad8c7431d0ca94acc51d161e7f4ad5a4b1f5d (diff)
downloadarchivator-d8be93a740e8cc8103c4f9e260a62244eba1a6a4.tar.gz
archivator-d8be93a740e8cc8103c4f9e260a62244eba1a6a4.zip
Add basic lib architecture
Diffstat (limited to 'src/result.rs')
-rw-r--r--src/result.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/result.rs b/src/result.rs
new file mode 100644
index 0000000..47302ae
--- /dev/null
+++ b/src/result.rs
@@ -0,0 +1,32 @@
1use std::error::Error;
2use std::fmt::{Debug, Display};
3use std::io;
4
5pub type ArchiveResult<R> = Result<R, ArchiveError>;
6
7#[derive(Debug)]
8pub enum ArchiveError {
9 IO(io::Error),
10}
11
12impl From<io::Error> for ArchiveError {
13 fn from(value: io::Error) -> Self {
14 Self::IO(value)
15 }
16}
17
18impl Display for ArchiveError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 Self::IO(err) => write!(f, "{err}"),
22 }
23 }
24}
25
26impl Error for ArchiveError {
27 fn source(&self) -> Option<&(dyn Error + 'static)> {
28 match self {
29 Self::IO(source) => Some(source),
30 }
31 }
32}