summary refs log tree commit diff
path: root/lib/src/error.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2020-11-30 15:15:54 -0800
committerIrene Knapp <ireneista@gmail.com>2020-11-30 15:15:54 -0800
commit19c26ff3a05e3af0cb88c5f5ac5799e57dbf021c (patch)
tree3fdb62527b9c8f0f0756d484bfc43feb70d99da8 /lib/src/error.rs
parent94f1a4f1245f69359aa6b1136742a0bbac3ae249 (diff)
Initial Rust stuff
Diffstat (limited to 'lib/src/error.rs')
-rw-r--r--lib/src/error.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/src/error.rs b/lib/src/error.rs
new file mode 100644
index 0000000..cd4a760
--- /dev/null
+++ b/lib/src/error.rs
@@ -0,0 +1,30 @@
+#[derive(Debug)]
+pub enum Error {
+    IO(std::io::Error),
+}
+
+impl std::error::Error for Error { }
+
+impl std::fmt::Display for Error {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Error::IO(e) => e.fmt(f),
+        }
+    }
+}
+
+impl std::cmp::PartialEq for Error {
+    fn eq(&self, other: &Self) -> bool {
+        match (self, other) {
+            (Error::IO(_), Error::IO(_)) =>
+                false,
+        }
+    }
+}
+
+impl From<std::io::Error> for Error {
+    fn from(e: std::io::Error) -> Error {
+        Error::IO(e)
+    }
+}
+