Change is_log() implementation to use kindflag utility

This patch changes the Log::is_log() implementation for Entry to use the
provide_kindflag_path!() infrastructure.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-05-17 22:44:29 +02:00
parent 9f100f2f75
commit c7f5420c1d
3 changed files with 11 additions and 5 deletions

View File

@ -24,6 +24,7 @@ toml = "0.4"
toml-query = "0.8"
failure = "0.1"
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
libimagdiary = { version = "0.10.0", path = "../../../lib/domain/libimagdiary" }
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
libimagdiary = { version = "0.10.0", path = "../../../lib/domain/libimagdiary" }
libimagentryutil = { version = "0.10.0", path = "../../../lib/entry/libimagentryutil" }

View File

@ -41,6 +41,7 @@ extern crate toml_query;
extern crate libimagdiary;
extern crate libimagstore;
#[macro_use] extern crate libimagentryutil;
pub mod log;

View File

@ -19,12 +19,14 @@
use libimagdiary::entry::DiaryEntry;
use libimagstore::store::Entry;
use libimagentryutil::isa::Is;
use libimagentryutil::isa::IsKindHeaderPathProvider;
use failure::Fallible as Result;
use failure::Error;
use toml::Value;
use toml_query::read::TomlValueReadTypeExt;
use toml_query::insert::TomlValueInsertExt;
pub trait Log : DiaryEntry {
@ -32,9 +34,11 @@ pub trait Log : DiaryEntry {
fn make_log_entry(&mut self) -> Result<()>;
}
provide_kindflag_path!(pub IsLog, "log.is_log");
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(Error::from)
self.is::<IsLog>().map_err(From::from)
}
fn make_log_entry(&mut self) -> Result<()> {