summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-04-13 23:08:36 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-04-13 23:08:36 +0200
commita4bcefe660468f740bf9a455c97b8be8e6cda0cc (patch)
tree34b17bb492986ef850fbb1388804e56ca5e6f28e
parentde522ec0f2acc4e3651f77fdbe7f5295b6702c0d (diff)
parentcb4d5367e44528a09a6e2cb36f4e7dc5cf85dbfb (diff)
downloadimag-a4bcefe660468f740bf9a455c97b8be8e6cda0cc.zip
imag-a4bcefe660468f740bf9a455c97b8be8e6cda0cc.tar.gz
Merge branch 'rewrite-module-entry-path'
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/core/libimagstore/src/storeid.rs45
-rw-r--r--lib/domain/libimagbookmark/src/collection.rs11
-rw-r--r--lib/domain/libimagbookmark/src/lib.rs2
-rw-r--r--lib/domain/libimagcontact/src/store.rs4
-rw-r--r--lib/domain/libimagdiary/src/diaryid.rs5
-rw-r--r--lib/domain/libimagdiary/src/lib.rs2
-rw-r--r--lib/domain/libimaghabit/src/habit.rs11
-rw-r--r--lib/domain/libimagmail/src/store.rs8
-rw-r--r--lib/domain/libimagnotes/src/lib.rs2
-rw-r--r--lib/domain/libimagnotes/src/notestore.rs12
-rw-r--r--lib/domain/libimagtimetrack/src/iter/storeid.rs6
-rw-r--r--lib/domain/libimagtimetrack/src/lib.rs2
-rw-r--r--lib/domain/libimagtodo/src/lib.rs2
-rw-r--r--lib/domain/libimagtodo/src/taskstore.rs41
-rw-r--r--lib/domain/libimagwiki/src/store.rs3
-rw-r--r--lib/domain/libimagwiki/src/wiki.rs21
-rw-r--r--lib/entry/libimagentryannotation/src/annotateable.rs7
-rw-r--r--lib/entry/libimagentrycategory/src/lib.rs2
-rw-r--r--lib/entry/libimagentrycategory/src/store.rs18
-rw-r--r--lib/entry/libimagentrylink/src/external.rs12
-rw-r--r--lib/entry/libimagentrylink/src/lib.rs2
21 files changed, 78 insertions, 140 deletions
diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs
index f269c39..56177ea 100644
--- a/lib/core/libimagstore/src/storeid.rs
+++ b/lib/core/libimagstore/src/storeid.rs
@@ -212,7 +212,7 @@ impl<'a> Display for StoreIdWithBase<'a> {
#[macro_export]
macro_rules! module_entry_path_mod {
($name:expr) => (
- #[deny(missing_docs,
+ #[allow(missing_docs,
missing_copy_implementations,
trivial_casts, trivial_numeric_casts,
unstable_features,
@@ -223,34 +223,23 @@ macro_rules! module_entry_path_mod {
use std::convert::AsRef;
use std::path::Path;
use std::path::PathBuf;
-
use $crate::storeid::StoreId;
use failure::Fallible as Result;
- /// A Struct giving you the ability to choose store entries assigned
- /// to it.
- ///
- /// It is created through a call to `new`.
- pub struct ModuleEntryPath(PathBuf);
-
- impl ModuleEntryPath {
- /// Path has to be a valid UTF-8 string or this will panic!
- pub fn new<P: AsRef<Path>>(pa: P) -> ModuleEntryPath {
- let mut path = PathBuf::new();
- path.push(format!("{}", $name));
- path.push(pa.as_ref().clone());
- let name = pa.as_ref().file_name().unwrap()
- .to_str().unwrap();
- path.set_file_name(name);
- ModuleEntryPath(path)
- }
- }
+ pub fn new_id<P: AsRef<Path>>(p: P) -> Result<StoreId> {
+
+ let path_str = p
+ .as_ref()
+ .to_str()
+ .ok_or_else(|| {
+ format_err!("File path is not valid UTF-8: {}", p.as_ref().display())
+ })?;
- impl $crate::storeid::IntoStoreId for ModuleEntryPath {
- fn into_storeid(self) -> Result<$crate::storeid::StoreId> {
- StoreId::new(self.0)
- }
+ let id = format!("{}/{}", $name, path_str);
+
+ StoreId::new(PathBuf::from(id))
}
+
}
)
}
@@ -351,20 +340,18 @@ impl<'a> StoreIdIteratorWithStore<'a> {
#[cfg(test)]
mod test {
- use storeid::IntoStoreId;
-
module_entry_path_mod!("test");
#[test]
fn test_correct_path() {
- let p = module_path::ModuleEntryPath::new("test");
+ let p = ::storeid::test::module_path::new_id("test");
- assert_eq!(p.into_storeid().unwrap().to_str().unwrap(), "test/test");
+ assert_eq!(p.unwrap().to_str().unwrap(), "test/test");
}
#[test]
fn storeid_in_collection() {
- let p = module_path::ModuleEntryPath::new("1/2/3/4/5/6/7/8/9/0").into_storeid().unwrap();
+ let p = ::storeid::test::module_path::new_id("1/2/3/4/5/6/7/8/9/0").unwrap();
assert!(p.is_in_collection(&["test", "1"]));
assert!(p.is_in_collection(&["test", "1", "2"]));
diff --git a/lib/domain/libimagbookmark/src/collection.rs b/lib/domain/libimagbookmark/src/collection.rs
index 853a761..47f2640 100644
--- a/lib/domain/libimagbookmark/src/collection.rs
+++ b/lib/domain/libimagbookmark/src/collection.rs
@@ -28,12 +28,10 @@ use regex::Regex;
use failure::Fallible as Result;
use failure::Error;
-use module_path::ModuleEntryPath;
use libimagstore::store::Store;
use libimagstore::store::Entry;
use libimagstore::store::FileLockEntry;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagentrylink::external::ExternalLinker;
use libimagentrylink::external::iter::UrlIter;
@@ -53,22 +51,19 @@ pub trait BookmarkCollectionStore<'a> {
impl<'a> BookmarkCollectionStore<'a> for Store {
fn new(&'a self, name: &str) -> Result<FileLockEntry<'a>> {
- ModuleEntryPath::new(name)
- .into_storeid()
+ ::module_path::new_id(name)
.and_then(|id| self.create(id).map_err(Error::from))
.map_err(Error::from)
}
fn get(&'a self, name: &str) -> Result<Option<FileLockEntry<'a>>> {
- ModuleEntryPath::new(name)
- .into_storeid()
+ ::module_path::new_id(name)
.and_then(|id| self.get(id).map_err(Error::from))
.map_err(Error::from)
}
fn delete(&'a self, name: &str) -> Result<()> {
- ModuleEntryPath::new(name)
- .into_storeid()
+ ::module_path::new_id(name)
.and_then(|id| self.delete(id).map_err(Error::from))
.map_err(Error::from)
}
diff --git a/lib/domain/libimagbookmark/src/lib.rs b/lib/domain/libimagbookmark/src/lib.rs
index c1dacef..6072070 100644
--- a/lib/domain/libimagbookmark/src/lib.rs
+++ b/lib/domain/libimagbookmark/src/lib.rs
@@ -39,7 +39,7 @@
extern crate url;
extern crate regex;
-extern crate failure;
+#[macro_use] extern crate failure;
#[macro_use] extern crate libimagstore;
extern crate libimagerror;
diff --git a/lib/domain/libimagcontact/src/store.rs b/lib/domain/libimagcontact/src/store.rs
index aab35ab..7c87783 100644
--- a/lib/domain/libimagcontact/src/store.rs
+++ b/lib/domain/libimagcontact/src/store.rs
@@ -27,7 +27,6 @@ use vobject::vcard::Vcard;
use failure::Error;
use failure::Fallible as Result;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagstore::iter::Entries;
use libimagstore::store::Store;
@@ -36,7 +35,6 @@ use libimagentryutil::isa::Is;
use contact::IsContact;
use deser::DeserVcard;
-use module_path::ModuleEntryPath;
use util;
pub trait ContactStore<'a> {
@@ -98,7 +96,7 @@ fn prepare_fetching_from_store(buf: &str) -> Result<(StoreId, Value)> {
toml_from_str::<Value>(&serialized)?
};
- let sid = ModuleEntryPath::new(uid.raw()).into_storeid()?;
+ let sid = ::module_path::new_id(uid.raw())?;
Ok((sid, value))
}
diff --git a/lib/domain/libimagdiary/src/diaryid.rs b/lib/domain/libimagdiary/src/diaryid.rs
index fb846db..2055099 100644
--- a/lib/domain/libimagdiary/src/diaryid.rs
+++ b/lib/domain/libimagdiary/src/diaryid.rs
@@ -34,8 +34,6 @@ use failure::err_msg;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
-use module_path::ModuleEntryPath;
-
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub struct DiaryId {
name: String,
@@ -150,8 +148,9 @@ impl DiaryId {
impl IntoStoreId for DiaryId {
fn into_storeid(self) -> Result<StoreId> {
+ use std::path::PathBuf;
let s : String = self.into();
- ModuleEntryPath::new(s).into_storeid()
+ ::module_path::new_id(PathBuf::from(s))
}
}
diff --git a/lib/domain/libimagdiary/src/lib.rs b/lib/domain/libimagdiary/src/lib.rs
index 7f0ce56..bd03f3f 100644
--- a/lib/domain/libimagdiary/src/lib.rs
+++ b/lib/domain/libimagdiary/src/lib.rs
@@ -42,7 +42,7 @@ extern crate chrono;
extern crate toml;
extern crate toml_query;
extern crate itertools;
-extern crate failure;
+#[macro_use] extern crate failure;
extern crate filters;
#[macro_use] extern crate libimagstore;
diff --git a/lib/domain/libimaghabit/src/habit.rs b/lib/domain/libimaghabit/src/habit.rs
index 188dcbb..2fcc33f 100644
--- a/lib/domain/libimaghabit/src/habit.rs
+++ b/lib/domain/libimaghabit/src/habit.rs
@@ -37,7 +37,6 @@ use libimagstore::store::Store;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Entry;
use libimagstore::storeid::StoreId;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagentryutil::isa::Is;
use libimagentryutil::isa::IsKindHeaderPathProvider;
@@ -258,11 +257,7 @@ impl HabitTemplate for Entry {
}
fn instance_id_for_name_and_datestr(habit_name: &String, habit_date: &String) -> Result<StoreId> {
- use module_path::ModuleEntryPath;
-
- ModuleEntryPath::new(format!("instance/{}-{}", habit_name, habit_date))
- .into_storeid()
- .map_err(Error::from)
+ ::module_path::new_id(format!("instance/{}-{}", habit_name, habit_date)).map_err(Error::from)
}
pub mod builder {
@@ -272,7 +267,6 @@ pub mod builder {
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
- use libimagstore::storeid::IntoStoreId;
use libimagstore::store::FileLockEntry;
use libimagentryutil::isa::Is;
use libimagutil::debug_result::DebugResult;
@@ -393,8 +387,7 @@ pub mod builder {
/// Buld a StoreId for a Habit from a date object and a name of a habit
fn build_habit_template_sid(name: &String) -> Result<StoreId> {
- use module_path::ModuleEntryPath;
- ModuleEntryPath::new(format!("template/{}", name)).into_storeid().map_err(From::from)
+ ::module_path::new_id(format!("template/{}", name)).map_err(From::from)
}
}
diff --git a/lib/domain/libimagmail/src/store.rs b/lib/domain/libimagmail/src/store.rs
index 6c672d9..3355a2c 100644
--- a/lib/domain/libimagmail/src/store.rs
+++ b/lib/domain/libimagmail/src/store.rs
@@ -27,7 +27,6 @@ use toml_query::insert::TomlValueInsertExt;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagstore::iter::Entries;
use libimagentryref::hasher::default::DefaultHasher;
@@ -36,7 +35,6 @@ use libimagentryref::reference::RefFassade;
use libimagentryref::reference::Ref;
use libimagentryref::reference::MutRef;
-use module_path::ModuleEntryPath;
use mid::MessageId;
use mail::Mail;
use hasher::MailHasher;
@@ -69,7 +67,7 @@ impl<'a> MailStore<'a> for Store {
CollName: AsRef<str> + Debug
{
let message_id = get_message_id_for_mailfile(p.as_ref())?;
- let new_sid = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
+ let new_sid = ::module_path::new_id(message_id.clone())?;
let mut entry = self.create(new_sid)?;
let _ = entry
@@ -90,7 +88,7 @@ impl<'a> MailStore<'a> for Store {
where P: AsRef<Path> + Debug
{
let message_id = get_message_id_for_mailfile(p.as_ref())?;
- let new_sid = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
+ let new_sid = ::module_path::new_id(message_id.clone())?;
match self.get(new_sid)? {
Some(mut entry) => {
@@ -117,7 +115,7 @@ impl<'a> MailStore<'a> for Store {
CollName: AsRef<str> + Debug
{
let message_id = get_message_id_for_mailfile(&p)?;
- let new_sid = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
+ let new_sid = ::module_path::new_id(message_id.clone())?;
let mut entry = self.retrieve(new_sid)?;
let _ = entry
diff --git a/lib/domain/libimagnotes/src/lib.rs b/lib/domain/libimagnotes/src/lib.rs
index 395c3cc..81b5a42 100644
--- a/lib/domain/libimagnotes/src/lib.rs
+++ b/lib/domain/libimagnotes/src/lib.rs
@@ -40,7 +40,7 @@
#[macro_use] extern crate log;
extern crate toml;
extern crate toml_query;
-extern crate failure;
+#[macro_use] extern crate failure;
extern crate libimagrt;
#[macro_use] extern crate libimagstore;
diff --git a/lib/domain/libimagnotes/src/notestore.rs b/lib/domain/libimagnotes/src/notestore.rs
index 87a26de..4245bce 100644
--- a/lib/domain/libimagnotes/src/notestore.rs
+++ b/lib/domain/libimagnotes/src/notestore.rs
@@ -19,14 +19,12 @@
use toml::Value;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use toml_query::insert::TomlValueInsertExt;
use failure::Fallible as Result;
-use module_path::ModuleEntryPath;
use iter::*;
pub trait NoteStore<'a> {
@@ -45,9 +43,7 @@ impl<'a> NoteStore<'a> for Store {
debug!("Creating new Note: '{}'", name);
let fle = {
- let mut lockentry = ModuleEntryPath::new(name.clone())
- .into_storeid()
- .and_then(|id| self.create(id))?;
+ let mut lockentry = ::module_path::new_id(name.clone()).and_then(|id| self.create(id))?;
{
let entry = lockentry.deref_mut();
@@ -62,15 +58,15 @@ impl<'a> NoteStore<'a> for Store {
}
fn delete_note(&'a self, name: String) -> Result<()> {
- ModuleEntryPath::new(name).into_storeid().and_then(|id| self.delete(id))
+ ::module_path::new_id(name).and_then(|id| self.delete(id))
}
fn retrieve_note(&'a self, name: String) -> Result<FileLockEntry<'a>> {
- ModuleEntryPath::new(name).into_storeid().and_then(|id| self.retrieve(id))
+ ::module_path::new_id(name).and_then(|id| self.retrieve(id))
}
fn get_note(&'a self, name: String) -> Result<Option<FileLockEntry<'a>>> {
- ModuleEntryPath::new(name).into_storeid().and_then(|id| self.get(id))
+ ::module_path::new_id(name).and_then(|id| self.get(id))
}
fn all_notes(&'a self) -> Result<NoteIterator> {
diff --git a/lib/domain/libimagtimetrack/src/iter/storeid.rs b/lib/domain/libimagtimetrack/src/iter/storeid.rs
index 620925d..2e2a047 100644
--- a/lib/domain/libimagtimetrack/src/iter/storeid.rs
+++ b/lib/domain/libimagtimetrack/src/iter/storeid.rs
@@ -49,16 +49,12 @@ impl Iterator for TagStoreIdIter {
type Item = Result<(StoreId, NDT)>;
fn next(&mut self) -> Option<Self::Item> {
- use module_path::ModuleEntryPath;
- use libimagstore::storeid::IntoStoreId;
-
self.inner
.next()
.map(|res| res.and_then(|tag| {
let dt = self.datetime.format(DATE_TIME_FORMAT).to_string();
let id_str = format!("{}-{}", dt, tag.as_str());
- ModuleEntryPath::new(id_str)
- .into_storeid()
+ ::module_path::new_id(id_str)
.map_err(Error::from)
.map(|id| (id, self.datetime.clone()))
}))
diff --git a/lib/domain/libimagtimetrack/src/lib.rs b/lib/domain/libimagtimetrack/src/lib.rs
index b006465..6335db1 100644
--- a/lib/domain/libimagtimetrack/src/lib.rs
+++ b/lib/domain/libimagtimetrack/src/lib.rs
@@ -45,7 +45,7 @@ extern crate toml_query;
extern crate lazy_static;
#[macro_use]
extern crate is_match;
-extern crate failure;
+#[macro_use] extern crate failure;
#[macro_use]
extern crate libimagstore;
diff --git a/lib/domain/libimagtodo/src/lib.rs b/lib/domain/libimagtodo/src/lib.rs
index 0adf888..bde8b81 100644
--- a/lib/domain/libimagtodo/src/lib.rs
+++ b/lib/domain/libimagtodo/src/lib.rs
@@ -42,7 +42,7 @@ extern crate toml;
extern crate toml_query;
#[macro_use] extern crate log;
extern crate serde_json;
-extern crate failure;
+#[macro_use] extern crate failure;
#[macro_use] extern crate libimagstore;
extern crate libimagerror;
diff --git a/lib/domain/libimagtodo/src/taskstore.rs b/lib/domain/libimagtodo/src/taskstore.rs
index aca7890..bbd2ae7 100644
--- a/lib/domain/libimagtodo/src/taskstore.rs
+++ b/lib/domain/libimagtodo/src/taskstore.rs
@@ -32,9 +32,7 @@ use failure::Error;
use failure::err_msg;
use libimagstore::store::{FileLockEntry, Store};
-use libimagstore::storeid::IntoStoreId;
use libimagerror::errors::ErrorMsg as EM;
-use module_path::ModuleEntryPath;
use iter::TaskIdIterator;
@@ -101,9 +99,7 @@ impl<'a> TaskStore<'a> for Store {
///
/// If there is no task with this UUID, this returns `Ok(None)`.
fn get_task_from_uuid(&'a self, uuid: Uuid) -> Result<Option<FileLockEntry<'a>>> {
- ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
- .into_storeid()
- .and_then(|store_id| self.get(store_id))
+ ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|store_id| self.get(store_id))
}
/// Same as Task::get_from_import() but uses Store::retrieve() rather than Store::get(), to
@@ -154,9 +150,7 @@ impl<'a> TaskStore<'a> for Store {
}
fn delete_task_by_uuid(&self, uuid: Uuid) -> Result<()> {
- ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
- .into_storeid()
- .and_then(|id| self.delete(id))
+ ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|id| self.delete(id))
}
fn all_tasks(&self) -> Result<TaskIdIterator> {
@@ -168,24 +162,21 @@ impl<'a> TaskStore<'a> for Store {
use toml_query::set::TomlValueSetExt;
let uuid = task.uuid();
- ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
- .into_storeid()
- .and_then(|id| {
- self.retrieve(id)
- .and_then(|mut fle| {
- {
- let hdr = fle.get_header_mut();
- if hdr.read("todo")?.is_none() {
- hdr.set("todo", Value::Table(BTreeMap::new()))?;
- }
-
- hdr.set("todo.uuid", Value::String(format!("{}",uuid)))?;
- }
-
- // If none of the errors above have returned the function, everything is fine
- Ok(fle)
- })
+ ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|id| {
+ self.retrieve(id).and_then(|mut fle| {
+ {
+ let hdr = fle.get_header_mut();
+ if hdr.read("todo")?.is_none() {
+ hdr.set("todo", Value::Table(BTreeMap::new()))?;
+ }
+
+ hdr.set("todo.uuid", Value::String(format!("{}",uuid)))?;
+ }
+
+ // If none of the errors above have returned the function, everything is fine
+ Ok(fle)
})
+ })
}
diff --git a/lib/domain/libimagwiki/src/store.rs b/lib/domain/libimagwiki/src/store.rs
index f052039..a1e93e8 100644
--- a/lib/domain/libimagwiki/src/store.rs
+++ b/lib/domain/libimagwiki/src/store.rs
@@ -20,7 +20,6 @@
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
-use libimagstore::storeid::IntoStoreId;
use failure::Fallible as Result;
@@ -83,6 +82,6 @@ impl WikiStore for Store {
}
fn wiki_path(name: &str) -> Result<StoreId> {
- ::module_path::ModuleEntryPath::new(name).into_storeid()
+ ::module_path::new_id(name)
}
diff --git a/lib/domain/libimagwiki/src/wiki.rs b/lib/domain/libimagwiki/src/wiki.rs
index 743536b..195f46e 100644
--- a/lib/domain/libimagwiki/src/wiki.rs
+++ b/lib/domain/libimagwiki/src/wiki.rs
@@ -21,7 +21,6 @@ use std::path::PathBuf;
use libimagstore::store::Store;
use libimagstore::store::FileLockEntry;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::iter::Entries;
use libimagentrylink::internal::InternalLinker;
@@ -48,14 +47,14 @@ impl<'a, 'b> Wiki<'a, 'b> {
pub(crate) fn create_index_page(&self) -> Result<FileLockEntry<'a>> {
let path = PathBuf::from(format!("{}/index", self.1));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let sid = ::module_path::new_id(path)?;
self.0.create(sid)
}
pub(crate) fn get_index_page(&self) -> Result<FileLockEntry<'a>> {
let path = PathBuf::from(format!("{}/index", self.1));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let sid = ::module_path::new_id(path)?;
self.0
.get(sid)
@@ -64,14 +63,14 @@ impl<'a, 'b> Wiki<'a, 'b> {
}
pub fn get_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<Option<FileLockEntry<'a>>> {
- let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
+ let sid = ::module_path::new_id(path)?;
self.0.get(sid)
}
pub fn create_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<FileLockEntry<'a>> {
- let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
+ let sid = ::module_path::new_id(path)?;
let mut index = self
.get_entry("index")?
.ok_or_else(|| err_msg("Missing index page"))?;
@@ -81,8 +80,8 @@ impl<'a, 'b> Wiki<'a, 'b> {
}
pub fn retrieve_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<FileLockEntry<'a>> {
- let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
+ let sid = ::module_path::new_id(path)?;
let mut index = self
.get_entry("index")?
.ok_or_else(|| err_msg("Missing index page"))?;
@@ -96,8 +95,8 @@ impl<'a, 'b> Wiki<'a, 'b> {
}
pub fn delete_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<()> {
- let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
- let sid = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
+ let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
+ let sid = ::module_path::new_id(path)?;
self.0.delete(sid)
}
}
diff --git a/lib/entry/libimagentryannotation/src/annotateable.rs b/lib/entry/libimagentryannotation/src/annotateable.rs
index 3c91584..19138e7 100644
--- a/lib/entry/libimagentryannotation/src/annotateable.rs
+++ b/lib/entry/libimagentryannotation/src/annotateable.rs
@@ -23,7 +23,6 @@ use uuid::Uuid;
use libimagstore::store::Entry;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
-use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagentrylink::internal::InternalLinker;
use libimagentryutil::isa::Is;
@@ -36,8 +35,6 @@ use failure::ResultExt;
use failure::Error;
use failure::err_msg;
-use module_path::ModuleEntryPath;
-
pub trait Annotateable {
fn annotate<'a>(&mut self, store: &'a Store) -> Result<FileLockEntry<'a>>;
fn denotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<Option<FileLockEntry<'a>>>;
@@ -54,7 +51,7 @@ impl Annotateable for Entry {
let ann_name = Uuid::new_v4().to_hyphenated().to_string();
debug!("Creating annotation with name = {}", ann_name);
- store.retrieve(ModuleEntryPath::new(ann_name.clone()).into_storeid()?)
+ store.retrieve(::module_path::new_id(ann_name.clone())?)
.and_then(|mut anno| {
{
let _ = anno.set_isflag::<IsAnnotation>()?;
@@ -76,7 +73,7 @@ impl Annotateable for Entry {
// Fails if there's no such annotation entry or if the link to that annotation entry does not
// exist.
fn denotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<Option<FileLockEntry<'a>>> {
- if let Some(mut annotation) = store.get(ModuleEntryPath::new(ann_name).into_storeid()?)? {
+ if let Some(mut annotation) = store.get(::module_path::new_id(ann_name)?)? {
let _ = self.remove_internal_link(&mut annotation)?;
Ok(Some(annotation))
} else {
diff --git a/lib/entry/libimagentrycategory/src/lib.rs b/lib/entry/libimagentrycategory/src/lib.rs
index a25813e..c8096bc 100644
--- a/lib/entry/libimagentrycategory/src/lib.rs
+++ b/lib/entry/libimagentrycategory/src/lib.rs
@@ -41,7 +41,7 @@ extern crate toml_query;
extern crate toml;
#[macro_use]
extern crate log;
-extern crate failure;
+#[macro_use] extern crate failure;
extern crate libimagerror;
#[macro_use] extern crate libimagstore;
diff --git a/lib/entry/libimagentrycategory/src/store.rs b/lib/entry/libimagentrycategory/src/store.rs
index 88746bb..508b3e8 100644
--- a/lib/entry/libimagentrycategory/src/store.rs
+++ b/lib/entry/libimagentrycategory/src/store.rs
@@ -17,8 +17,6 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
-use std::path::PathBuf;
-
use toml_query::insert::TomlValueInsertExt;
use toml_query::read::TomlValueReadTypeExt;
use toml::Value;
@@ -60,7 +58,7 @@ impl CategoryStore for Store {
/// Check whether a category exists
fn category_exists(&self, name: &str) -> Result<bool> {
trace!("Category exists? '{}'", name);
- let sid = mk_category_storeid(self.path().clone(), name)?;
+ let sid = mk_category_storeid(name)?;
represents_category(self, sid, name)
}
@@ -69,7 +67,7 @@ impl CategoryStore for Store {
/// Fails if the category already exists (returns false then)
fn create_category<'a>(&'a self, name: &str) -> Result<FileLockEntry<'a>> {
trace!("Creating category: '{}'", name);
- let sid = mk_category_storeid(self.path().clone(), name)?;
+ let sid = mk_category_storeid(name)?;
let mut entry = self.create(sid)?;
entry.set_isflag::<IsCategory>()?;
@@ -90,7 +88,7 @@ impl CategoryStore for Store {
use category::Category;
trace!("Deleting category: '{}'", name);
- let sid = mk_category_storeid(self.path().clone(), name)?;
+ let sid = mk_category_storeid(name)?;
{
let mut category = self.get(sid.clone())?
@@ -118,7 +116,7 @@ impl CategoryStore for Store {
/// like a normal file in the store (which is exactly what it is).
fn get_category_by_name(&self, name: &str) -> Result<Option<FileLockEntry>> {
trace!("Getting category by name: '{}'", name);
- let sid = mk_category_storeid(self.path().clone(), name)?;
+ let sid = mk_category_storeid(name)?;
self.get(sid)
.context(err_msg("Store write error"))
@@ -209,12 +207,8 @@ mod tests {
}
#[inline]
-fn mk_category_storeid(base: PathBuf, s: &str) -> Result<StoreId> {
- use libimagstore::storeid::IntoStoreId;
- ::module_path::ModuleEntryPath::new(s)
- .into_storeid()
- .context(err_msg("Store id handling error"))
- .map_err(Error::from)
+fn mk_category_storeid(s: &str) -> Result<StoreId> {
+ ::module_path::new_id(s).context(err_msg("Store id handling error")).map_err(Error::from)
}
#[inline]
diff --git a/lib/entry/libimagentrylink/src/external.rs b/lib/entry/libimagentrylink/src/external.rs
index bfce70a..9362723 100644
--- a/lib/entry/libimagentrylink/src/external.rs
+++ b/lib/entry/libimagentrylink/src/external.rs
@@ -37,7 +37,6 @@ use std::fmt::Debug;
use libimagstore::store::Entry;
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
-use libimagstore::storeid::IntoStoreId;
use libimagutil::debug_result::*;
use libimagerror::errors::ErrorMsg as EM;
@@ -50,7 +49,6 @@ use failure::ResultExt;
use failure::err_msg;
use internal::InternalLinker;
-use module_path::ModuleEntryPath;
use self::iter::*;
@@ -337,12 +335,10 @@ impl ExternalLinker for Entry {
debug!("Iterating {} links = {:?}", links.len(), links);
links.into_iter().map(|link| {
let hash = hex::encode(Sha1::digest(&link.as_str().as_bytes()));
- let file_id =
- ModuleEntryPath::new(format!("external/{}", hash)).into_storeid()
- .map_dbg_err(|_| {
- format!("Failed to build StoreId for this hash '{:?}'", hash)
- })
- ?;
+ let file_id = ::module_path::new_id(format!("external/{}", hash))
+ .map_dbg_err(|_| {
+ format!("Failed to build StoreId for this hash '{:?}'", hash)
+ })?;
debug!("Link = '{:?}'", link);
debug!("Hash = '{:?}'", hash);
diff --git a/lib/entry/libimagentrylink/src/lib.rs b/lib/entry/libimagentrylink/src/lib.rs
index 2ef064b..ce25881 100644
--- a/lib/entry/libimagentrylink/src/lib.rs
+++ b/lib/entry/libimagentrylink/src/lib.rs
@@ -44,8 +44,8 @@ extern crate toml_query;
extern crate url;
extern crate sha1;
extern crate hex;
-#[macro_use] extern crate is_match;
#[macro_use] extern crate failure;
+#[macro_use] extern crate is_match;
#[cfg(test)]
extern crate env_logger;