summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-03-06 13:49:31 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-03-06 13:49:31 +0100
commite770c79f53cee69dc42eb41d52adfb01501ba073 (patch)
tree5dc67292c4fe4984e8b9bda1a9ad953c69417d72
parent2efb030c3d543b19cc358d47205c11123933a180 (diff)
Remove unused io error handling code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/core/libimagerror/src/io.rs62
-rw-r--r--lib/core/libimagerror/src/lib.rs1
2 files changed, 0 insertions, 63 deletions
diff --git a/lib/core/libimagerror/src/io.rs b/lib/core/libimagerror/src/io.rs
deleted file mode 100644
index 753fff6e..00000000
--- a/lib/core/libimagerror/src/io.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015-2020 the imag contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-use std::io::ErrorKind;
-
-use crate::exit::ExitCode;
-
-pub enum Settings {
- Ignore(ErrorKind),
- IgnoreAny(Vec<ErrorKind>),
-}
-
-pub trait ToExitCode<T> {
- fn to_exit_code(self) -> Result<T, ExitCode>;
- fn to_exit_code_with(self, _: Settings) -> Result<T, ExitCode>;
-}
-
-impl<T> ToExitCode<T> for Result<T, ::std::io::Error> {
-
- /// Returns an exit code of 0 if the error was a broken pipe, else 1
- fn to_exit_code(self) -> Result<T, ExitCode> {
- self.to_exit_code_with(Settings::Ignore(ErrorKind::BrokenPipe))
- }
-
- /// Returns an exit code depending on the settings
- ///
- /// Via the settings, errors can be ignores (translates to exit code zero). All other errors
- /// are translated into exit code 1
- ///
- fn to_exit_code_with(self, settings: Settings) -> Result<T, ExitCode> {
- self.map_err(move |e| match settings {
- Settings::Ignore(kind) => if e.kind() == kind {
- 0
- } else {
- 1
- },
- Settings::IgnoreAny(v) => if v.iter().any(|el| e.kind() == *el) {
- 0
- } else {
- 1
- },
- })
- .map_err(ExitCode::from)
- }
-
-}
diff --git a/lib/core/libimagerror/src/lib.rs b/lib/core/libimagerror/src/lib.rs
index fc3a33cf..5b373b0b 100644
--- a/lib/core/libimagerror/src/lib.rs
+++ b/lib/core/libimagerror/src/lib.rs
@@ -42,7 +42,6 @@ extern crate failure;
pub mod errors;
pub mod exit;
-pub mod io;
pub mod str;
pub mod trace;