summaryrefslogtreecommitdiffstats
path: root/libimagtodo
diff options
context:
space:
mode:
authormario <mario-krehl@gmx.de>2016-06-28 20:30:54 +0200
committermario <mario-krehl@gmx.de>2016-06-28 20:30:54 +0200
commit3a9128ec7bc061c5d35f4a6425df8d7cd236cca0 (patch)
tree4f7b6870bfe1d2d4ed49efb0df9fa679679c35b1 /libimagtodo
parent48de71d926f735b7cb331a5befcac76b85eec12e (diff)
various fixes like indentation and function names.
also moved the Result type definition to an extra file/module.
Diffstat (limited to 'libimagtodo')
-rw-r--r--libimagtodo/src/add.rs0
-rw-r--r--libimagtodo/src/read.rs31
-rw-r--r--libimagtodo/src/result.rs5
-rw-r--r--libimagtodo/src/set.rs0
-rw-r--r--libimagtodo/src/task.rs5
5 files changed, 21 insertions, 20 deletions
diff --git a/libimagtodo/src/add.rs b/libimagtodo/src/add.rs
deleted file mode 100644
index e69de29b..00000000
--- a/libimagtodo/src/add.rs
+++ /dev/null
diff --git a/libimagtodo/src/read.rs b/libimagtodo/src/read.rs
index 9129fb60..4af86d61 100644
--- a/libimagtodo/src/read.rs
+++ b/libimagtodo/src/read.rs
@@ -1,16 +1,11 @@
-
use libimagstore::storeid::{StoreIdIterator, StoreId};
use libimagstore::store::Store;
use error::{TodoError, TodoErrorKind};
use task::Task;
+use result::Result;
-use std::result::Result as RResult;
-
-pub type Result<T> = RResult<T, TodoError>;
-
+pub fn get_todo_iterator(store: &Store) -> Result<TaskIterator> {
-pub fn all_todos(store: &Store) -> Result<TaskIterator> {
-
store.retrieve_for_module("uuid")
.map(|iter| TaskIterator::new(store, iter))
.map_err(|e| TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e))))
@@ -23,10 +18,10 @@ trait FromStoreId {
impl<'a> FromStoreId for Task<'a> {
fn from_storeid<'b>(store: &'b Store, id: StoreId) -> Result<Task<'b>> {
- match store.retrieve(id) {
- Err(e) => Err(TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e)))),
- Ok(c) => Ok(Task::new( c )),
- }
+ match store.retrieve(id) {
+ Err(e) => Err(TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e)))),
+ Ok(c) => Ok(Task::new( c )),
+ }
}
}
@@ -38,10 +33,10 @@ pub struct TaskIterator<'a> {
impl<'a> TaskIterator<'a> {
pub fn new(store: &'a Store, iditer: StoreIdIterator) -> TaskIterator<'a> {
- TaskIterator {
- store: store,
- iditer: iditer,
- }
+ TaskIterator {
+ store: store,
+ iditer: iditer,
+ }
}
}
@@ -49,8 +44,8 @@ impl<'a> Iterator for TaskIterator<'a> {
type Item = Result<Task<'a>>;
fn next(&mut self) -> Option<Result<Task<'a>>> {
- self.iditer
- .next()
- .map(|id| Task::from_storeid(self.store, id))
+ self.iditer
+ .next()
+ .map(|id| Task::from_storeid(self.store, id))
}
}
diff --git a/libimagtodo/src/result.rs b/libimagtodo/src/result.rs
new file mode 100644
index 00000000..2c254210
--- /dev/null
+++ b/libimagtodo/src/result.rs
@@ -0,0 +1,5 @@
+use error::{TodoError, TodoErrorKind};
+
+use std::result::Result as RResult;
+
+pub type Result<T> = RResult<T, TodoError>;
diff --git a/libimagtodo/src/set.rs b/libimagtodo/src/set.rs
deleted file mode 100644
index e69de29b..00000000
--- a/libimagtodo/src/set.rs
+++ /dev/null
diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs
index e8384a73..5fe55990 100644
--- a/libimagtodo/src/task.rs
+++ b/libimagtodo/src/task.rs
@@ -9,6 +9,7 @@ use libimagstore::storeid::IntoStoreId;
use module_path::ModuleEntryPath;
use error::{TodoError, TodoErrorKind};
+use result::Result;
/// Task struct containing a `FileLockEntry`
#[derive(Debug)]
@@ -43,10 +44,10 @@ pub trait IntoTask<'a> {
/// println!("Task with uuid: {}", task.flentry.get_header().get("todo.uuid"));
/// }
/// ```
- fn into_filelockentry(self, store : &'a Store) -> Result<Task<'a>, TodoError>;
+ fn into_filelockentry(self, store : &'a Store) -> Result<Task<'a>>;
}
impl<'a> IntoTask<'a> for TTask {
- fn into_filelockentry(self, store : &'a Store) -> Result<Task<'a>, TodoError> {
+ fn into_filelockentry(self, store : &'a Store) -> Result<Task<'a>> {
let uuid = self.uuid();
let store_id = ModuleEntryPath::new(format!("taskwarrior/{}", uuid)).into_storeid();
match store.retrieve(store_id) {