diff options
| -rw-r--r-- | src/database.rs | 2 | ||||
| -rw-r--r-- | src/ffi.rs | 6 | ||||
| -rw-r--r-- | src/query.rs | 18 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/database.rs b/src/database.rs index 85ddcfb..b0e8b75 100644 --- a/src/database.rs +++ b/src/database.rs @@ -189,7 +189,7 @@ impl Database { pub fn create_query(&self, query_string: &String) -> Result<Query> { let query_str = CString::new(query_string.as_str()).unwrap(); - + println!("query {:?}", query_str); let mut query = ptr::null_mut(); unsafe { query = ffi::notmuch_query_create(self.0, query_str.as_ptr()); @@ -731,9 +731,9 @@ extern { /// to call it if the query is about to be destroyed). /// /// @since libnotmuch 4.2 (notmuch 0.20) - pub fn notmuch_query_search_threads( - query: *mut notmuch_query_t, - ) -> *mut notmuch_threads_t; + pub fn notmuch_query_search_threads(query: *mut notmuch_query_t, + out: *mut *mut notmuch_threads_t) + -> notmuch_status_t; /// Execute a query for messages, returning a `notmuch_messages_t` object /// which can be used to iterate over the results. The returned diff --git a/src/query.rs b/src/query.rs index 6d7da64..68e9baf 100644 --- a/src/query.rs +++ b/src/query.rs @@ -13,6 +13,7 @@ use utils::{ }; use Database; use Messages; +use Threads; use ffi::Sort; #[derive(Debug)] @@ -53,7 +54,7 @@ impl<'d> Query<'d> { pub fn search_messages(self: &Self) -> Result<Option<Messages>> { let mut msgs = ptr::null_mut(); - try!(unsafe { + let ret = try!(unsafe { ffi::notmuch_query_search_messages( self.0, &mut msgs, ) @@ -64,6 +65,21 @@ impl<'d> Query<'d> { true => Ok(Some(Messages::new(msgs))), } } + + pub fn search_threads(self: &Self) -> Result<Option<Threads>> + { + let mut thrds = ptr::null_mut(); + let ret = try!(unsafe { + ffi::notmuch_query_search_threads( + self.0, &mut thrds, + ) + }.as_result()); + + match thrds.is_null() { + false => Ok(None), + true => Ok(Some(Threads::new(thrds))), + } + } } impl<'d> NewFromPtr<*mut ffi::notmuch_query_t> for Query<'d> { |
