From ba417206ed8bb2341dcad5655d91ad09f6a0f073 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 23 Mar 2018 07:28:07 +0100 Subject: thread: count messages and files --- src/ffi.rs | 11 +++++++++++ src/thread.rs | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ffi.rs b/src/ffi.rs index 765b180..db67390 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -907,6 +907,17 @@ extern { thread: *mut notmuch_thread_t, ) -> c_int; + /// Get the total number of files in 'thread'. + /// + /// This sums notmuch_message_count_files over all messages in the + /// thread + /// @returns Non-negative integer + /// @since libnotmuch 5.0 (notmuch 0.25) + /// + pub fn notmuch_thread_get_total_files( + thread: *mut notmuch_thread_t, + ) -> c_int; + /// Get a `notmuch_messages_t` iterator for the top-level messages in /// 'thread' in oldest-first order. /// diff --git a/src/thread.rs b/src/thread.rs index cf5440c..2a502b4 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -25,12 +25,22 @@ impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'q, 'd> { } } -// impl<'d> Thread<'d>( -// -// -// -// }; -// +impl<'q, 'd> Thread<'q, 'd>{ + + pub fn total_messages(self: &Self) -> i32{ + unsafe { + ffi::notmuch_thread_get_total_messages(self.0) + } + } + + pub fn total_files(self: &Self) -> i32{ + unsafe { + ffi::notmuch_thread_get_total_files(self.0) + } + } + +} + impl<'q, 'd> ops::Drop for Thread<'q, 'd> { fn drop(&mut self) { -- cgit v1.2.1