aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-23 06:49:37 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-23 06:49:37 +0100
commit257e61b035c8fa80458f3aa44e068a3522b6686c (patch)
treea0aaab9cd09cea6b02cdd500d1cd8469d25a346d /src
parentccfa3d4864ff043abf1800e5397251afad7693d5 (diff)
downloadmail-257e61b035c8fa80458f3aa44e068a3522b6686c.tar.gz
search threads
Diffstat (limited to 'src')
-rw-r--r--src/database.rs2
-rw-r--r--src/ffi.rs6
-rw-r--r--src/query.rs18
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());
diff --git a/src/ffi.rs b/src/ffi.rs
index 76045e3..caecc0e 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -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> {