diff --git a/lib/domain/libimagcontact/Cargo.toml b/lib/domain/libimagcontact/Cargo.toml index ef3d35dd..90d4a758 100644 --- a/lib/domain/libimagcontact/Cargo.toml +++ b/lib/domain/libimagcontact/Cargo.toml @@ -23,4 +23,5 @@ vobject = "0.4" libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore" } libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" } libimagentryref = { version = "0.6.0", path = "../../../lib/entry/libimagentryref/" } +libimagentryutil = { version = "0.6.0", path = "../../../lib/entry/libimagentryutil/" } diff --git a/lib/domain/libimagcontact/src/contact.rs b/lib/domain/libimagcontact/src/contact.rs index 14a80e3b..6b112125 100644 --- a/lib/domain/libimagcontact/src/contact.rs +++ b/lib/domain/libimagcontact/src/contact.rs @@ -20,14 +20,12 @@ use std::ops::Deref; use vobject::Component; -use toml::Value; -use toml_query::read::TomlValueReadExt; use libimagstore::store::Entry; use libimagentryref::reference::Ref; +use libimagentryutil::isa::Is; +use libimagentryutil::isa::IsKindHeaderPathProvider; -use error::ContactError as CE; -use error::ContactErrorKind as CEK; use error::Result; use util; @@ -46,15 +44,12 @@ pub trait Contact : Ref { } +provide_kindflag_path!(pub IsContact, "contact.is_contact"); + impl Contact for Entry { fn is_contact(&self) -> Result { - let location = "contact.marker"; - match self.get_header().read(location)? { - Some(&Value::Boolean(b)) => Ok(b), - Some(_) => Err(CE::from_kind(CEK::HeaderTypeError("boolean", location))), - None => Ok(false) - } + self.is::().map_err(From::from) } fn get_contact_data(&self) -> Result { diff --git a/lib/domain/libimagcontact/src/error.rs b/lib/domain/libimagcontact/src/error.rs index c3c81472..93f5d15e 100644 --- a/lib/domain/libimagcontact/src/error.rs +++ b/lib/domain/libimagcontact/src/error.rs @@ -28,6 +28,7 @@ error_chain! { StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind); RefError(::libimagentryref::error::RefError, ::libimagentryref::error::RefErrorKind); VObjectError(::vobject::error::VObjectError, ::vobject::error::VObjectErrorKind); + EntryUtilError(::libimagentryutil::error::EntryUtilError, ::libimagentryutil::error::EntryUtilErrorKind); } foreign_links { diff --git a/lib/domain/libimagcontact/src/lib.rs b/lib/domain/libimagcontact/src/lib.rs index efdb8a60..134a3206 100644 --- a/lib/domain/libimagcontact/src/lib.rs +++ b/lib/domain/libimagcontact/src/lib.rs @@ -42,6 +42,7 @@ extern crate toml_query; #[macro_use] extern crate libimagstore; extern crate libimagerror; extern crate libimagentryref; +#[macro_use] extern crate libimagentryutil; module_entry_path_mod!("contact"); diff --git a/lib/domain/libimagcontact/src/store.rs b/lib/domain/libimagcontact/src/store.rs index 770c08ff..505fa57d 100644 --- a/lib/domain/libimagcontact/src/store.rs +++ b/lib/domain/libimagcontact/src/store.rs @@ -20,15 +20,15 @@ use std::path::PathBuf; use vobject::parse_component; -use toml::Value; -use toml_query::insert::TomlValueInsertExt; use libimagstore::store::Store; use libimagstore::store::FileLockEntry; use libimagstore::storeid::StoreIdIterator; use libimagentryref::refstore::RefStore; use libimagentryref::flags::RefFlags; +use libimagentryutil::isa::Is; +use contact::IsContact; use error::Result; use util; @@ -71,8 +71,7 @@ impl<'a> ContactStore<'a> for Store { RefStore::create(self, p.clone(), flags) .map_err(From::from) .and_then(|mut entry| { - entry.get_header_mut() - .insert("contact.marker", Value::Boolean(true)) + entry.set_isflag::() .map_err(From::from) .map(|_| entry) })