From df5abef44795ee4c6710232909ef1f2e98b87083 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jul 2016 20:08:50 +0200 Subject: [PATCH] Move delete functionality to the place where it belongs --- libimagtodo/src/delete.rs | 19 ------------------- libimagtodo/src/lib.rs | 1 - libimagtodo/src/task.rs | 6 ++++++ 3 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 libimagtodo/src/delete.rs diff --git a/libimagtodo/src/delete.rs b/libimagtodo/src/delete.rs deleted file mode 100644 index ed56dc0c..00000000 --- a/libimagtodo/src/delete.rs +++ /dev/null @@ -1,19 +0,0 @@ -use uuid::Uuid; - -use libimagstore::store::Store; -use libimagstore::storeid::IntoStoreId; -use module_path::ModuleEntryPath; - -use error::{TodoError, TodoErrorKind}; - -/// With the uuid we get the storeid and then we can delete the entry -pub fn delete(store : &Store, uuid: Uuid) -> Result<(),TodoError> { - // With the uuid we get the storeid - let store_id = ModuleEntryPath::new(format!("taskwarrior/{}", uuid)).into_storeid(); - // It deletes an entry - match store.delete(store_id) { - Ok(val) => Ok(val), - Err(e) => Err(TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e)))), - } -} - diff --git a/libimagtodo/src/lib.rs b/libimagtodo/src/lib.rs index 0396704a..cf1f966c 100644 --- a/libimagtodo/src/lib.rs +++ b/libimagtodo/src/lib.rs @@ -7,7 +7,6 @@ extern crate task_hookrs; module_entry_path_mod!("todo", "0.1.0"); -pub mod delete; pub mod error; pub mod read; pub mod result; diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs index 0c68e4c0..ebfb4b7e 100644 --- a/libimagtodo/src/task.rs +++ b/libimagtodo/src/task.rs @@ -2,6 +2,7 @@ use std::collections::BTreeMap; use std::ops::{Deref, DerefMut}; use toml::Value; +use uuid::Uuid; use task_hookrs::task::Task as TTask; @@ -23,6 +24,11 @@ impl<'a> Task<'a> { Task(fle) } + 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)))) + } + } impl<'a> Deref for Task<'a> {