Move delete functionality to the place where it belongs
This commit is contained in:
parent
07ab966d37
commit
df5abef447
3 changed files with 6 additions and 20 deletions
|
@ -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)))),
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue