libimaglog: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
57f7a5a682
commit
1956099e2e
4 changed files with 7 additions and 45 deletions
|
@ -21,8 +21,8 @@ maintenance = { status = "actively-developed" }
|
|||
|
||||
[dependencies]
|
||||
toml = "0.4"
|
||||
toml-query = "0.7"
|
||||
error-chain = "0.12"
|
||||
toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" }
|
||||
failure = "0.1"
|
||||
|
||||
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" }
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// imag - the personal information management suite for the commandline
|
||||
// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and 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
|
||||
//
|
||||
|
||||
error_chain! {
|
||||
types {
|
||||
LogError, LogErrorKind, ResultExt, Result;
|
||||
}
|
||||
|
||||
foreign_links {
|
||||
TomlQueryError(::toml_query::error::Error);
|
||||
}
|
||||
|
||||
errors {
|
||||
HeaderTypeError(expected: &'static str, got: &'static str) {
|
||||
description("Header Type Error")
|
||||
display("Error: Expected {} in header, got {}", expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,14 +33,12 @@
|
|||
while_true,
|
||||
)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate failure;
|
||||
extern crate toml;
|
||||
extern crate toml_query;
|
||||
|
||||
extern crate libimagdiary;
|
||||
extern crate libimagstore;
|
||||
|
||||
pub mod error;
|
||||
pub mod log;
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
use libimagdiary::entry::DiaryEntry;
|
||||
use libimagstore::store::Entry;
|
||||
|
||||
use error::LogError as LE;
|
||||
use error::Result;
|
||||
use failure::Fallible as Result;
|
||||
use failure::Error;
|
||||
|
||||
use toml::Value;
|
||||
use toml_query::read::TomlValueReadTypeExt;
|
||||
|
@ -34,13 +34,13 @@ pub trait Log : DiaryEntry {
|
|||
|
||||
impl Log for Entry {
|
||||
fn is_log(&self) -> Result<bool> {
|
||||
self.get_header().read_bool("log.is_log").map(|v| v.unwrap_or(false)).map_err(From::from)
|
||||
self.get_header().read_bool("log.is_log").map(|v| v.unwrap_or(false)).map_err(Error::from)
|
||||
}
|
||||
|
||||
fn make_log_entry(&mut self) -> Result<()> {
|
||||
self.get_header_mut()
|
||||
.insert("log.is_log", Value::Boolean(true))
|
||||
.map_err(LE::from)
|
||||
.map_err(Error::from)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue