Add Contact::is_contact()
This commit is contained in:
parent
f2bd241a59
commit
12e8657eb9
1 changed files with 15 additions and 0 deletions
|
@ -18,10 +18,14 @@
|
|||
//
|
||||
|
||||
use vobject::Component;
|
||||
use toml::Value;
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
|
||||
use libimagstore::store::Entry;
|
||||
use libimagentryref::reference::Ref;
|
||||
|
||||
use error::ContactError as CE;
|
||||
use error::ContactErrorKind as CEK;
|
||||
use error::Result;
|
||||
use util;
|
||||
|
||||
|
@ -30,6 +34,8 @@ use util;
|
|||
/// Based on the functionality from libimagentryref, for fetching the Ical data from disk
|
||||
pub trait Contact : Ref {
|
||||
|
||||
fn is_contact(&self) -> Result<bool>;
|
||||
|
||||
// getting data
|
||||
|
||||
fn get_contact_data(&self) -> Result<ContactData>;
|
||||
|
@ -40,6 +46,15 @@ pub trait Contact : Ref {
|
|||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_contact_data(&self) -> Result<ContactData> {
|
||||
let component = self
|
||||
.fs_file()
|
||||
|
|
Loading…
Reference in a new issue