aboutsummaryrefslogtreecommitdiffstats
path: root/src/message.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/message.rs')
-rw-r--r--src/message.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/message.rs b/src/message.rs
index 81d2417..094f5dc 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -1,6 +1,9 @@
use std::ops::Drop;
use std::marker::PhantomData;
use std::path::PathBuf;
+use std::ffi::CString;
+
+use error::{Error, Result};
use ffi;
use utils::{
@@ -63,6 +66,18 @@ impl<'d, 'q> Message<'d, 'q>{
ffi::notmuch_message_get_filename(self.0)
}.to_str().unwrap())
}
+
+ pub fn header(&self, name: &str) -> Result<&str> {
+ let ret = unsafe {
+ ffi::notmuch_message_get_header(self.0,
+ CString::new(name).unwrap().as_ptr())
+ };
+ if ret.is_null() {
+ Err(Error::UnspecifiedError)
+ } else {
+ Ok(ret.to_str().unwrap())
+ }
+ }
}