Add flag settings/Contact::is_contact in libimagcontact
This commit is contained in:
parent
7fb13acf15
commit
9a9701fce5
5 changed files with 11 additions and 14 deletions
|
@ -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/" }
|
||||
|
||||
|
|
|
@ -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<bool> {
|
||||
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::<IsContact>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn get_contact_data(&self) -> Result<ContactData> {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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::<IsContact>()
|
||||
.map_err(From::from)
|
||||
.map(|_| entry)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue