aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/filenames.rs9
-rw-r--r--src/message.rs21
2 files changed, 25 insertions, 5 deletions
diff --git a/src/filenames.rs b/src/filenames.rs
index 618d7a8..5d6a19c 100644
--- a/src/filenames.rs
+++ b/src/filenames.rs
@@ -4,6 +4,11 @@ use std::{
iter
};
+use std::path::{
+ PathBuf,
+ Path
+};
+
use std::ffi::{
CString,
CStr
@@ -37,7 +42,7 @@ impl<'d> ops::Drop for Filenames<'d> {
}
impl<'d> iter::Iterator for Filenames<'d> {
- type Item = String;
+ type Item = PathBuf;
fn next(&mut self) -> Option<Self::Item> {
@@ -54,6 +59,6 @@ impl<'d> iter::Iterator for Filenames<'d> {
CStr::from_ptr(ffi::notmuch_filenames_get(self.0))
};
- Some(ctag.to_str().unwrap().to_string())
+ Some(PathBuf::from(ctag.to_str().unwrap()))
}
}
diff --git a/src/message.rs b/src/message.rs
index eb94cc8..6edfd7e 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -6,6 +6,8 @@ use std::{
result
};
+use std::path::PathBuf;
+
use error::Result;
use ffi;
@@ -31,11 +33,18 @@ 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 {
+ pub fn id(self: &Self) -> String{
+ let mid = unsafe {
ffi::notmuch_message_get_message_id(self.0)
};
- tid.to_str()
+ mid.to_str().unwrap().to_string()
+ }
+
+ pub fn thread_id(self: &Self) -> String{
+ let tid = unsafe {
+ ffi::notmuch_message_get_thread_id(self.0)
+ };
+ tid.to_str().unwrap().to_string()
}
pub fn replies(self: &Self) -> Messages<'q, 'd>{
@@ -56,6 +65,12 @@ impl<'q, 'd> Message<'q, 'd>{
ffi::notmuch_message_get_filenames(self.0)
})
}
+
+ pub fn filename(self: &Self) -> PathBuf{
+ PathBuf::from(unsafe {
+ ffi::notmuch_message_get_filename(self.0)
+ }.to_str().unwrap())
+ }
}