summaryrefslogtreecommitdiffstats
path: root/libimagtodo
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-07-10 16:50:18 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-07-21 17:14:12 +0200
commitf3639d34ebcead1840aa7160cdae12e701038d0c (patch)
tree4a8c012264b585b1eb49405f590a62111183550f /libimagtodo
parentb918f4abbe095f1cba64a187824fb55bd5620700 (diff)
Add more required functionality, not implemented yet
Diffstat (limited to 'libimagtodo')
-rw-r--r--libimagtodo/src/task.rs112
1 files changed, 112 insertions, 0 deletions
diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs
index bc306b80..fa92a8de 100644
--- a/libimagtodo/src/task.rs
+++ b/libimagtodo/src/task.rs
@@ -37,6 +37,118 @@ impl<'a> Task<'a> {
})
}
+ /// Get a task from an import string. That is: read the imported string, get the UUID from it
+ /// and try to load this UUID from store.
+ ///
+ /// Possible return values are:
+ ///
+ /// * Ok(Ok(Task))
+ /// * Ok(Err(String)) - where the String is the String read from the `r` parameter
+ /// * Err(_) - where the error is an error that happened during evaluation
+ ///
+ pub fn get_from_import<R: BufRead>(store: &'a Store, mut r: R) -> Result<RResult<Task<'a>, String>>
+ {
+ unimplemented!()
+ }
+
+ /// Get a task from a String. The String is expected to contain the JSON-representation of the
+ /// Task to get from the store (only the UUID really matters in this case)
+ pub fn get_from_string(store: &'a Store, s: String) -> Result<Task<'a>> {
+ unimplemented!()
+ }
+
+ /// Get a task from an UUID.
+ pub fn get_from_uuid(store: &'a Store, uuid: Uuid) -> Result<Task<'a>> {
+ unimplemented!()
+ }
+
+ /// Same as Task::get_from_import() but uses Store::retrieve() rather than Store::get(), to
+ /// implicitely create the task if it does not exist.
+ pub fn retrieve_from_import<R: BufRead>(store: &'a Store, mut r: R) -> Result<Task<'a>> {
+ unimplemented!()
+ }
+
+ /// Retrieve a task from a String. The String is expected to contain the JSON-representation of
+ /// the Task to retrieve from the store (only the UUID really matters in this case)
+ pub fn retrieve_from_string(store: &'a Store, s: String) -> Result<Task<'a>> {
+ unimplemented!()
+ }
+
+ /// Retrieve a task from an UUID.
+ pub fn retrieve_from_uuid(store: &'a Store, uuid: Uuid) -> Result<Task<'a>> {
+ unimplemented!()
+ }
+
+ /// Call `Task::update_from_imports_with()` function with `Task::copy_information()`
+ pub fn update_from_imports<R: BufRead>(store: &'a Store, mut r: R) -> Result<(Task<'a>,
+ Task<'a>)> {
+ unimplemented!()
+ }
+
+ /// Call `Task::update_from_strings_with()` function with `Task::copy_information()`
+ pub fn update_from_strings<R>(store: &'a Store, old_t: String, new_t: String) -> Result<(Task<'a>, Task<'a>)>
+ where R: BufRead
+ {
+ unimplemented!()
+ }
+
+ /// Call `Task::update_from_uuid_and_string_with()` function with `Task::copy_information()`
+ pub fn update_from_uuid_and_string<R>(store: &'a Store, old_t: Uuid, new_t: String) -> Result<(Task<'a>, Task<'a>)>
+ where R: BufRead
+ {
+ unimplemented!()
+ }
+
+ /// Update a task from imports.
+ ///
+ /// Expects the `r` variable to return two JSON objects, the first one beeing the Task before
+ /// the modification, the second one after the modification.
+ ///
+ /// It then tries to load the first task, getting the corrosponding object from the store,
+ /// and updating the task with the new information. That is
+ ///
+ /// * Writing a new task object to the store
+ /// * Copying all information from the header of the old task to the new task via
+ /// the passed copy-functionality
+ /// * Returning both Task objects in a tuple (old, new)
+ ///
+ pub fn update_from_imports_with<R, F>(store: &'a Store, mut r: R, f: F) -> Result<(Task<'a>, Task<'a>)>
+ where R: BufRead,
+ F: Fn(&mut Task<'a>, &mut Task<'a>) -> Result<()>
+ {
+ unimplemented!()
+ }
+
+ /// Same as `Task::update_from_imports_with()` but with two Strings rather than reading from a
+ /// BufRead. Expects both Strings to contain readable JSON.
+ pub fn update_from_strings_with<R, F>(store: &'a Store, old_t: String, new_t: String, f: F) -> Result<(Task<'a>, Task<'a>)>
+ where R: BufRead,
+ F: Fn(&mut Task<'a>, &mut Task<'a>) -> Result<()>
+ {
+ unimplemented!()
+ }
+
+ /// Same as `Task::update_from_strings_with()` but with the parameter for the old task beeing
+ /// the uuid of the task.
+ pub fn update_from_uuid_and_string_with<R, F>(store: &'a Store, old_t: Uuid, new_t: String, f: F) -> Result<(Task<'a>, Task<'a>)>
+ where R: BufRead,
+ F: Fn(&mut Task<'a>, &mut Task<'a>) -> Result<()>
+ {
+ unimplemented!()
+ }
+
+ /// Copy information from one task to the second task. This function can be used to copy
+ /// information from one task to another.
+ ///
+ /// Two kinds of informations are copied:
+ ///
+ /// 1. links (via libimagentrylink)
+ /// 1. tags (via libimagentrytag)
+ ///
+ pub fn copy_information(old_task: &mut Task<'a>, new_task: &mut Task<'a>) -> Result<()> {
+ unimplemented!()
+ }
+
pub fn delete_by_uuid(store: &Store, uuid: Uuid) -> Result<()> {
store.delete(ModuleEntryPath::new(format!("taskwarrior/{}", uuid)).into_storeid())
.map_err(|e| TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e))))