aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ffi.rs8
-rw-r--r--src/query.rs30
2 files changed, 35 insertions, 3 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index caecc0e..58965cc 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -856,7 +856,8 @@ extern {
/// @since libnotmuch 4.3 (notmuch 0.21)
pub fn notmuch_query_count_messages(
query: *mut notmuch_query_t,
- ) -> c_uint;
+ count: *mut c_uint
+ ) -> notmuch_status_t;
/// Return the number of threads matching a search.
@@ -879,9 +880,10 @@ extern {
/// value of *count is not defined.
///
/// @since libnotmuch 4.3 (notmuch 0.21)
- pub fn notmuch_count_threads(
+ pub fn notmuch_query_count_threads(
query: *mut notmuch_query_t,
- ) -> c_uint;
+ count: *mut c_uint
+ ) -> notmuch_status_t;
/// Get the thread ID of 'thread'.
///
diff --git a/src/query.rs b/src/query.rs
index 68e9baf..2873b27 100644
--- a/src/query.rs
+++ b/src/query.rs
@@ -66,6 +66,21 @@ impl<'d> Query<'d> {
}
}
+ pub fn count_messages(self: &Self) -> Result<u32>
+ {
+ let mut cnt = 0;
+ let ret = try!(unsafe {
+ ffi::notmuch_query_count_messages(
+ self.0, &mut cnt,
+ )
+ }.as_result());
+
+ // if ret.is_err(){
+ // return ret;
+ // }
+ return Ok(cnt);
+ }
+
pub fn search_threads(self: &Self) -> Result<Option<Threads>>
{
let mut thrds = ptr::null_mut();
@@ -80,6 +95,21 @@ impl<'d> Query<'d> {
true => Ok(Some(Threads::new(thrds))),
}
}
+
+ pub fn count_threads(self: &Self) -> Result<u32>
+ {
+ let mut cnt = 0;
+ let ret = try!(unsafe {
+ ffi::notmuch_query_count_threads(
+ self.0, &mut cnt,
+ )
+ }.as_result());
+
+ // if ret.is_err(){
+ // return ret;
+ // }
+ return Ok(cnt);
+ }
}
impl<'d> NewFromPtr<*mut ffi::notmuch_query_t> for Query<'d> {