From 688a4eb106db42cb50509c61216efc42bf3a4b1f Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 23 Mar 2018 12:20:57 +0100 Subject: get thread authors and subject --- src/thread.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/thread.rs b/src/thread.rs index 87e1f0c..2182d69 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -32,11 +32,11 @@ impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'q, 'd> { impl<'q, 'd> Thread<'q, 'd>{ - pub fn id(self: &Self) -> result::Result<&'q str, str::Utf8Error>{ + pub fn id(self: &Self) -> String{ let tid = unsafe { ffi::notmuch_thread_get_thread_id(self.0) }; - tid.to_str() + tid.to_str().unwrap().to_string() } @@ -74,6 +74,24 @@ impl<'q, 'd> Thread<'q, 'd>{ }) } + pub fn subject(self: &Self) -> String{ + let sub = unsafe { + ffi::notmuch_thread_get_subject(self.0) + }; + + sub.to_str().unwrap().to_string() + } + + pub fn authors(self: &Self) -> Vec{ + let athrs = unsafe { + ffi::notmuch_thread_get_authors(self.0) + }; + + athrs.to_str().unwrap().split(",").map(|s| s.to_string()).collect() + } + + + } -- cgit v1.2.1