aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-23 11:56:52 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-03-23 11:56:52 +0100
commit7719c3b31f67eded7af6cd63d99b56c0f74c97cd (patch)
tree9baa207493944912204e4452ccad85c8e6170d13
parentc7f1127b960d1208b12a1abbd33885826fb6dd0c (diff)
downloadmail-7719c3b31f67eded7af6cd63d99b56c0f74c97cd.tar.gz
wip
-rw-r--r--src/ffi.rs7
-rw-r--r--src/message.rs35
-rw-r--r--src/messages.rs11
-rw-r--r--src/thread.rs24
4 files changed, 76 insertions, 1 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index db67390..d181ea0 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -1149,6 +1149,13 @@ extern {
message: *mut notmuch_message_t,
) -> *mut notmuch_messages_t;
+ /// Get the total number of files associated with a message.
+ /// @returns Non-negative integer
+ /// @since libnotmuch 5.0 (notmuch 0.25)
+ pub fn notmuch_message_count_files(
+ message: *mut notmuch_message_t,
+ ) -> c_int;
+
/// Get a filename for the email corresponding to 'message'.
///
/// The returned filename is an absolute filename, (the initial
diff --git a/src/message.rs b/src/message.rs
index 79fb19c..eb94cc8 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -2,7 +2,8 @@ use std;
use std::{
ops,
marker,
- ptr,
+ str,
+ result
};
use error::Result;
@@ -10,8 +11,11 @@ use error::Result;
use ffi;
use utils::{
NewFromPtr,
+ ToStr
};
use Query;
+use Messages;
+use Filenames;
#[derive(Debug)]
pub struct Message<'q, 'd:'q>(
@@ -25,6 +29,35 @@ impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'q, 'd> {
}
}
+impl<'q, 'd> Message<'q, 'd>{
+
+ pub fn id(self: &Self) -> result::Result<&'q str, str::Utf8Error>{
+ let tid = unsafe {
+ ffi::notmuch_message_get_message_id(self.0)
+ };
+ tid.to_str()
+ }
+
+ pub fn replies(self: &Self) -> Messages<'q, 'd>{
+ Messages::new(unsafe {
+ ffi::notmuch_message_get_replies(self.0)
+ })
+ }
+
+ pub fn count_files(self: &Self) -> i32
+ {
+ unsafe {
+ ffi::notmuch_message_count_files(self.0)
+ }
+ }
+
+ pub fn filenames(self: &Self) -> Filenames<'d>{
+ Filenames::new(unsafe {
+ ffi::notmuch_message_get_filenames(self.0)
+ })
+ }
+}
+
impl<'q, 'd> ops::Drop for Message<'q, 'd> {
fn drop(&mut self) {
diff --git a/src/messages.rs b/src/messages.rs
index bb86866..8466387 100644
--- a/src/messages.rs
+++ b/src/messages.rs
@@ -12,6 +12,7 @@ use utils::{
};
use Query;
use Message;
+use Tags;
#[derive(Debug)]
pub struct Messages<'q, 'd:'q>(
@@ -27,6 +28,16 @@ impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_messages_t> for Messages<'q, 'd> {
}
}
+impl<'q, 'd> Messages<'q, 'd>{
+
+ pub fn collect_tags(self: &Self) -> Tags{
+ Tags::new(unsafe {
+ ffi::notmuch_messages_collect_tags(self.0)
+ })
+ }
+
+}
+
impl<'q, 'd> ops::Drop for Messages<'q, 'd> {
fn drop(&mut self) {
unsafe {
diff --git a/src/thread.rs b/src/thread.rs
index 2743f0a..87e1f0c 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -15,6 +15,8 @@ use utils::{
ToStr
};
use Query;
+use Messages;
+use Tags;
#[derive(Debug)]
pub struct Thread<'q, 'd:'q>(
@@ -50,6 +52,28 @@ impl<'q, 'd> Thread<'q, 'd>{
}
}
+
+ pub fn toplevel_messages(self: &Self) -> Messages{
+ Messages::new(unsafe {
+ ffi::notmuch_thread_get_toplevel_messages(self.0)
+ })
+ }
+
+ /// Get a `Messages` iterator for all messages in 'thread' in
+ /// oldest-first order.
+ pub fn messages(self: &Self) -> Messages{
+ Messages::new(unsafe {
+ ffi::notmuch_thread_get_messages(self.0)
+ })
+ }
+
+
+ pub fn tags(self: &Self) -> Tags{
+ Tags::new(unsafe {
+ ffi::notmuch_thread_get_tags(self.0)
+ })
+ }
+
}