diff options
| author | eaon <eaon@mit.edu> | 2018-11-21 04:36:29 +0100 |
|---|---|---|
| committer | eaon <eaon@mit.edu> | 2018-11-21 04:36:29 +0100 |
| commit | 47a084069c9b253dc5ec5c92c14527845ed89bec (patch) | |
| tree | eb9b50f7ebdb05f775441e271a3fe31076f59f9d | |
| parent | 7f14f694090b097dd486cab79c0b54235b2eb6d6 (diff) | |
| download | mail-47a084069c9b253dc5ec5c92c14527845ed89bec.tar.gz | |
Match up Database::remove_message with Message::filename return type
| -rw-r--r-- | src/database.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/database.rs b/src/database.rs index 8f365cb..82579f3 100644 --- a/src/database.rs +++ b/src/database.rs @@ -243,7 +243,7 @@ impl Database { pub fn remove_message<'d, P>(&'d self, path: &P) -> Status where - P: AsRef<str>, + P: AsRef<Path>, { <Self as DatabaseExt>::remove_message(self, path) } @@ -299,14 +299,19 @@ pub trait DatabaseExt { fn remove_message<'d, D, P>(database: D, path: &P) -> Status where D: Into<Supercow<'d, Database>>, - P: AsRef<str>, + P: AsRef<Path>, { 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()) - }) + match path.as_ref().to_str() { + Some(path_str) => { + let msg_path = CString::new(path_str).unwrap(); + + Status::from(unsafe { + ffi::notmuch_database_remove_message(dbref.handle.ptr, msg_path.as_ptr()) + }) + } + None => Status::FileError + } } } |
