summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2020-01-05 20:44:27 +0100
committertomsmeding <tom.smeding@gmail.com>2020-01-05 20:44:27 +0100
commit8421f2c03d6f905b58b5447a6e0469519c7f8fa6 (patch)
tree6258db477e638c43a6c51cb0549c070fb0f8f9b2 /src/error.rs
Initial
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..6358bfe
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,23 @@
+use std::io;
+
+pub trait IntoIOError {
+ fn ioerr(self) -> io::Error;
+}
+
+impl IntoIOError for String {
+ fn ioerr(self) -> io::Error {
+ io::Error::new(io::ErrorKind::Other, self)
+ }
+}
+
+impl IntoIOError for &str {
+ fn ioerr(self) -> io::Error {
+ io::Error::new(io::ErrorKind::Other, self)
+ }
+}
+
+impl IntoIOError for std::string::FromUtf8Error {
+ fn ioerr(self) -> io::Error {
+ io::Error::new(io::ErrorKind::Other, self)
+ }
+}