From 3eab3af7b08789ac2e0c7765a104c20ff9788ba7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 25 Apr 2018 11:28:40 +0200 Subject: [PATCH] Remove all libimagentryref usage --- lib/domain/libimagcontact/Cargo.toml | 6 --- lib/domain/libimagcontact/src/contact.rs | 13 +----- lib/domain/libimagcontact/src/error.rs | 1 - lib/domain/libimagcontact/src/iter.rs | 7 --- lib/domain/libimagcontact/src/lib.rs | 1 - lib/domain/libimagcontact/src/store.rs | 55 +++--------------------- 6 files changed, 7 insertions(+), 76 deletions(-) diff --git a/lib/domain/libimagcontact/Cargo.toml b/lib/domain/libimagcontact/Cargo.toml index 84ea6c03..4c4c4d2f 100644 --- a/lib/domain/libimagcontact/Cargo.toml +++ b/lib/domain/libimagcontact/Cargo.toml @@ -33,12 +33,6 @@ libimagstore = { version = "0.8.0", path = "../../../lib/core/libimagstore" libimagerror = { version = "0.8.0", path = "../../../lib/core/libimagerror" } libimagentryutil = { version = "0.8.0", path = "../../../lib/entry/libimagentryutil/" } -[dependencies.libimagentryref] -version = "0.8.0" -path = "../../../lib/entry/libimagentryref/" -default-features = false -features = ["generators", "generators-sha1"] - [features] default = [] deser = ["serde", "serde_derive"] diff --git a/lib/domain/libimagcontact/src/contact.rs b/lib/domain/libimagcontact/src/contact.rs index 375eeed4..b35ee5b8 100644 --- a/lib/domain/libimagcontact/src/contact.rs +++ b/lib/domain/libimagcontact/src/contact.rs @@ -22,7 +22,6 @@ use std::ops::Deref; use vobject::Component; use libimagstore::store::Entry; -use libimagentryref::reference::Ref; use libimagentryutil::isa::Is; use libimagentryutil::isa::IsKindHeaderPathProvider; @@ -30,9 +29,7 @@ use error::Result; use util; /// Trait to be implemented on ::libimagstore::store::Entry -/// -/// Based on the functionality from libimagentryref, for fetching the Ical data from disk -pub trait Contact : Ref { +pub trait Contact { fn is_contact(&self) -> Result; @@ -53,13 +50,7 @@ impl Contact for Entry { } fn get_contact_data(&self) -> Result { - let component = self - .get_path() - .map_err(From::from) - .and_then(util::read_to_string) - .and_then(util::parse)?; - - Ok(ContactData(component)) + unimplemented!() } } diff --git a/lib/domain/libimagcontact/src/error.rs b/lib/domain/libimagcontact/src/error.rs index 37ff4c26..eb44b3b2 100644 --- a/lib/domain/libimagcontact/src/error.rs +++ b/lib/domain/libimagcontact/src/error.rs @@ -26,7 +26,6 @@ error_chain! { links { 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); } diff --git a/lib/domain/libimagcontact/src/iter.rs b/lib/domain/libimagcontact/src/iter.rs index 8e66c833..1f99c873 100644 --- a/lib/domain/libimagcontact/src/iter.rs +++ b/lib/domain/libimagcontact/src/iter.rs @@ -29,13 +29,6 @@ use error::Result; pub struct ContactIter<'a>(StoreIdIterator, &'a Store); /// Iterator over contacts -/// -/// As the libimagcontact works with libimagentryref in the backend, we must hold a reference to the -/// Store here as well, so we can check whether a fetched StoreId actually points to a contact -/// reference or not. -/// -/// So, the Iterator `Store::get()`s the object pointed to by the StoreId and returns it if -/// everything worked. impl<'a> ContactIter<'a> { pub fn new(sii: StoreIdIterator, store: &'a Store) -> ContactIter<'a> { diff --git a/lib/domain/libimagcontact/src/lib.rs b/lib/domain/libimagcontact/src/lib.rs index 6e55e570..f16d07e8 100644 --- a/lib/domain/libimagcontact/src/lib.rs +++ b/lib/domain/libimagcontact/src/lib.rs @@ -42,7 +42,6 @@ extern crate uuid; #[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 02ac57c2..8529eb0d 100644 --- a/lib/domain/libimagcontact/src/store.rs +++ b/lib/domain/libimagcontact/src/store.rs @@ -26,8 +26,6 @@ use vobject::parse_component; use libimagstore::store::Store; use libimagstore::store::FileLockEntry; use libimagstore::storeid::StoreIdIterator; -use libimagentryref::refstore::RefStore; -use libimagentryref::refstore::UniqueRefPathGenerator; use libimagentryutil::isa::Is; use contact::IsContact; @@ -36,45 +34,14 @@ use error::ContactErrorKind as CEK; use error::Result; use util; -pub struct UniqueContactPathGenerator; -impl UniqueRefPathGenerator for UniqueContactPathGenerator { - type Error = CE; - - /// The collection the `StoreId` should be created for - fn collection() -> &'static str { - "contact" - } - - /// A function which should generate a unique string for a Path - fn unique_hash>(path: A) -> RResult { - use vobject::vcard::Vcard; - - debug!("Generating unique hash for path: {:?}", path.as_ref()); - util::read_to_string(path.as_ref()) - .and_then(|s| Vcard::build(&s).map_err(CE::from)) - .and_then(|card| { - card.uid() - .map(|u| u.raw().clone()) - .ok_or_else(|| { - let s = path.as_ref().to_str().unwrap_or("Unknown path"); - CEK::UidMissing(String::from(s)).into() - }) - }) - } - -} - -pub trait ContactStore<'a> : RefStore<'a> { +pub trait ContactStore<'a> { // creating fn create_from_path(&'a self, p: &PathBuf) -> Result>; /// Create contact ref from buffer - /// - /// Needs the `p` argument as we're finally creating a reference by path, the buffer is only for - /// collecting metadata. - fn create_from_buf>(&'a self, p: P, buf: &String) -> Result>; + fn create_from_buf(&'a self, buf: &String) -> Result>; // getting @@ -82,30 +49,18 @@ pub trait ContactStore<'a> : RefStore<'a> { } /// The extension for the Store to work with contacts -/// -/// The contact functionality is implemented by using the `libimagentryref` library, so basically -/// we only reference vcard files from outside the store. -/// -/// Because of this, we do not have an own store collection `/contacts` or something like that, but -/// must stress the `libimagentryref` API for everything. impl<'a> ContactStore<'a> for Store { fn create_from_path(&'a self, p: &PathBuf) -> Result> { - util::read_to_string(p).and_then(|buf| self.create_from_buf(p, &buf)) + util::read_to_string(p).and_then(|buf| self.create_from_buf(&buf)) } /// Create contact ref from buffer - fn create_from_buf>(&'a self, p: P, buf: &String) -> Result> { + fn create_from_buf(&'a self, buf: &String) -> Result> { let component = parse_component(&buf)?; debug!("Parsed: {:?}", component); - RefStore::create_ref::(self, p) - .map_err(From::from) - .and_then(|mut entry| { - entry.set_isflag::() - .map_err(From::from) - .map(|_| entry) - }) + unimplemented!() } fn all_contacts(&'a self) -> Result {