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:
parent
9f100f2f75
commit
c7f5420c1d
3 changed files with 11 additions and 5 deletions
|
@ -24,6 +24,7 @@ toml = "0.4"
|
||||||
toml-query = "0.8"
|
toml-query = "0.8"
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
|
|
||||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||||
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
|
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
|
||||||
libimagdiary = { version = "0.10.0", path = "../../../lib/domain/libimagdiary" }
|
libimagdiary = { version = "0.10.0", path = "../../../lib/domain/libimagdiary" }
|
||||||
|
libimagentryutil = { version = "0.10.0", path = "../../../lib/entry/libimagentryutil" }
|
||||||
|
|
|
@ -41,6 +41,7 @@ extern crate toml_query;
|
||||||
|
|
||||||
extern crate libimagdiary;
|
extern crate libimagdiary;
|
||||||
extern crate libimagstore;
|
extern crate libimagstore;
|
||||||
|
#[macro_use] extern crate libimagentryutil;
|
||||||
|
|
||||||
pub mod log;
|
pub mod log;
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
|
|
||||||
use libimagdiary::entry::DiaryEntry;
|
use libimagdiary::entry::DiaryEntry;
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
|
use libimagentryutil::isa::Is;
|
||||||
|
use libimagentryutil::isa::IsKindHeaderPathProvider;
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
use toml_query::read::TomlValueReadTypeExt;
|
|
||||||
use toml_query::insert::TomlValueInsertExt;
|
use toml_query::insert::TomlValueInsertExt;
|
||||||
|
|
||||||
pub trait Log : DiaryEntry {
|
pub trait Log : DiaryEntry {
|
||||||
|
@ -32,9 +34,11 @@ pub trait Log : DiaryEntry {
|
||||||
fn make_log_entry(&mut self) -> Result<()>;
|
fn make_log_entry(&mut self) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provide_kindflag_path!(pub IsLog, "log.is_log");
|
||||||
|
|
||||||
impl Log for Entry {
|
impl Log for Entry {
|
||||||
fn is_log(&self) -> Result<bool> {
|
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<()> {
|
fn make_log_entry(&mut self) -> Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue