aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-22 20:06:50 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-22 20:06:50 +0100
commit9c51895af08f367c112e77634cb534ecdc430bbf (patch)
treee4adfbd15823b1872285b9d441ab1d625a63b6fb /src
parent95053bfc0010cb0bc00154a12f154063b6134375 (diff)
downloadmail-9c51895af08f367c112e77634cb534ecdc430bbf.tar.gz
slightly better interface, but still returning a null pointer...
Diffstat (limited to 'src')
-rw-r--r--src/ffi.rs9
-rw-r--r--src/query.rs19
2 files changed, 16 insertions, 12 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index b5dcca3..e341df8 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -751,9 +751,12 @@ extern {
/// If a Xapian exception occurs this function will return NULL.
///
/// @since libnotmuch 4.2 (notmuch 0.20)
- pub fn notmuch_query_search_messages(
- query: *mut notmuch_query_t,
- ) -> *mut notmuch_messages_t;
+ pub fn notmuch_query_search_messages(query: *mut notmuch_query_t,
+ out: *mut *mut notmuch_messages_t)
+ -> notmuch_status_t;
+ pub fn notmuch_query_search_messages_st(query: *mut notmuch_query_t,
+ out: *mut *mut notmuch_messages_t)
+ -> notmuch_status_t;
/// Destroy a `notmuch_query_t` along with any associated resources.
///
diff --git a/src/query.rs b/src/query.rs
index 2fbe031..654d4c6 100644
--- a/src/query.rs
+++ b/src/query.rs
@@ -28,18 +28,19 @@ impl<'d> Query<'d> {
}
/// Filter messages according to the query and return
- pub fn search_messages(self: &Self) -> std::result::Result<Messages, ()>
+ pub fn search_messages(self: &Self) -> Result<Option<Messages>>
{
let mut msgs = ptr::null_mut();
- unsafe {
- msgs = ffi::notmuch_query_search_messages(self.0);
- }
- if !msgs.is_null() {
- return Ok(Messages::new(msgs));
- }else{
- return Err(());
+ try!(unsafe {
+ ffi::notmuch_query_search_messages(
+ self.0, &mut msgs,
+ )
+ }.as_result());
+
+ match msgs.is_null() {
+ false => Ok(None),
+ true => Ok(Some(Messages::new(msgs))),
}
-
}
}