diff options
Diffstat (limited to 'src/message.rs')
| -rw-r--r-- | src/message.rs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/message.rs b/src/message.rs index 624817d..ed72997 100644 --- a/src/message.rs +++ b/src/message.rs @@ -5,6 +5,7 @@ use supercow::Phantomcow; use error::{Error, Result}; use ffi; +use ffi::Status; use utils::ToStr; use Filenames; use FilenamesOwner; @@ -57,7 +58,7 @@ impl<'o, Owner: MessageOwner + 'o> Message<'o, Owner> { tid.to_str().unwrap().to_string() } - pub fn replies<'s>(self: &'s Self) -> Messages<'s, Self> { + pub fn replies(self: &Self) -> Messages<Self> { Messages::from_ptr( unsafe { ffi::notmuch_message_get_replies(self.handle.ptr) }, self, @@ -84,9 +85,16 @@ impl<'o, Owner: MessageOwner + 'o> Message<'o, Owner> { ) } + pub fn date(&self) -> i64 { + unsafe { + ffi::notmuch_message_get_date(self.handle.ptr) + } + } + pub fn header(&self, name: &str) -> Result<&str> { + let name = CString::new(name).unwrap(); let ret = unsafe { - ffi::notmuch_message_get_header(self.handle.ptr, CString::new(name).unwrap().as_ptr()) + ffi::notmuch_message_get_header(self.handle.ptr, name.as_ptr()) }; if ret.is_null() { Err(Error::UnspecifiedError) @@ -95,12 +103,32 @@ impl<'o, Owner: MessageOwner + 'o> Message<'o, Owner> { } } - pub fn tags<'m>(&'m self) -> Tags<'m, Self> { + pub fn tags(&self) -> Tags<Self> { Tags::from_ptr( unsafe { ffi::notmuch_message_get_tags(self.handle.ptr) }, self, ) } + + pub fn add_tag(self: &Self, tag: &str) -> Status { + let tag = CString::new(tag).unwrap(); + Status::from(unsafe { + ffi::notmuch_message_add_tag(self.handle.ptr, tag.as_ptr()) + }) + } + + pub fn remove_tag(self: &Self, tag: &str) -> Status { + let tag = CString::new(tag).unwrap(); + Status::from(unsafe { + ffi::notmuch_message_remove_tag(self.handle.ptr, tag.as_ptr()) + }) + } + + pub fn remove_all_tags(self: &Self) -> Status { + Status::from(unsafe { + ffi::notmuch_message_remove_all_tags(self.handle.ptr) + }) + } } unsafe impl<'o, Owner: MessageOwner + 'o> Send for Message<'o, Owner> {} |
