diff options
| author | eaon <eaon@mit.edu> | 2018-11-19 23:21:58 +0100 |
|---|---|---|
| committer | eaon <eaon@mit.edu> | 2018-11-19 23:37:07 +0100 |
| commit | d4d8969c83077b409137a32c11e6b18b6ca2fdff (patch) | |
| tree | dcfcf34f6567ea447ccd67671373fa3f70e47d61 | |
| parent | ad70f33648245764c2d02bde14207f9b86bfe016 (diff) | |
| download | mail-d4d8969c83077b409137a32c11e6b18b6ca2fdff.tar.gz | |
Add Database::remove_message
| -rw-r--r-- | src/database.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/database.rs b/src/database.rs index d5e6700..8f365cb 100644 --- a/src/database.rs +++ b/src/database.rs @@ -9,6 +9,7 @@ use libc; use error::Result; use ffi; +use ffi::Status; use query::QueryPtr; use utils::ToStr; use Directory; @@ -140,8 +141,7 @@ impl Database { }, status.map_or(ptr::null_mut(), |f| &f as *const _ as *mut libc::c_void), ) - } - .as_result() + }.as_result() ); Ok(()) @@ -220,8 +220,7 @@ impl Database { }, status.map_or(ptr::null_mut(), |f| &f as *const _ as *mut libc::c_void), ) - } - .as_result() + }.as_result() ); Ok(()) @@ -241,6 +240,13 @@ impl Database { pub fn all_tags<'d>(&'d self) -> Result<Tags<'d, Self>> { <Self as DatabaseExt>::all_tags(self) } + + pub fn remove_message<'d, P>(&'d self, path: &P) -> Status + where + P: AsRef<str>, + { + <Self as DatabaseExt>::remove_message(self, path) + } } pub trait DatabaseExt { @@ -280,8 +286,7 @@ pub trait DatabaseExt { try!( unsafe { ffi::notmuch_database_get_directory(dbref.handle.ptr, path_str.as_ptr(), &mut dir) - } - .as_result() + }.as_result() ); if dir.is_null() { @@ -290,6 +295,19 @@ pub trait DatabaseExt { Ok(Some(Directory::from_ptr(dir, Supercow::phantom(dbref)))) } } + + fn remove_message<'d, D, P>(database: D, path: &P) -> Status + where + D: Into<Supercow<'d, Database>>, + P: AsRef<str>, + { + let dbref = database.into(); + let msg_path = CString::new(path.as_ref()).unwrap(); + + Status::from(unsafe { + ffi::notmuch_database_remove_message(dbref.handle.ptr, msg_path.as_ptr()) + }) + } } impl DatabaseExt for Database {} |
