diff options
Diffstat (limited to 'lib/domain/libimagmail/src/mail.rs')
-rw-r--r-- | lib/domain/libimagmail/src/mail.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/domain/libimagmail/src/mail.rs b/lib/domain/libimagmail/src/mail.rs index d48ce002..78d2e67a 100644 --- a/lib/domain/libimagmail/src/mail.rs +++ b/lib/domain/libimagmail/src/mail.rs @@ -27,6 +27,8 @@ use libimagentryutil::isa::IsKindHeaderPathProvider; use libimagentryref::reference::Config as RefConfig; use libimagentryref::reference::{Ref, RefFassade}; +use crate::mid::MessageId; + provide_kindflag_path!(pub IsMail, "mail.is_mail"); pub trait Mail : RefFassade { @@ -35,8 +37,8 @@ pub trait Mail : RefFassade { fn get_from(&self, refconfig: &RefConfig) -> Result<Option<String>>; fn get_to(&self, refconfig: &RefConfig) -> Result<Option<String>>; fn get_subject(&self, refconfig: &RefConfig) -> Result<Option<String>>; - fn get_message_id(&self, refconfig: &RefConfig) -> Result<Option<String>>; - fn get_in_reply_to(&self, refconfig: &RefConfig) -> Result<Option<String>>; + fn get_message_id(&self, refconfig: &RefConfig) -> Result<Option<MessageId>>; + fn get_in_reply_to(&self, refconfig: &RefConfig) -> Result<Option<MessageId>>; } impl Mail for Entry { @@ -110,9 +112,9 @@ impl Mail for Entry { /// # Note /// /// Use `Mail::mail_header()` if you need to read more than one field. - fn get_message_id(&self, refconfig: &RefConfig) -> Result<Option<String>> { + fn get_message_id(&self, refconfig: &RefConfig) -> Result<Option<MessageId>> { self.get_field(refconfig, "Message-ID") - .map(|o| o.map(crate::util::strip_message_delimiters)) + .map(|o| o.map(crate::util::strip_message_delimiters).map(MessageId::from)) } /// Get a value of the `In-Reply-To` field of the mail file @@ -120,8 +122,9 @@ impl Mail for Entry { /// # Note /// /// Use `Mail::mail_header()` if you need to read more than one field. - fn get_in_reply_to(&self, refconfig: &RefConfig) -> Result<Option<String>> { + fn get_in_reply_to(&self, refconfig: &RefConfig) -> Result<Option<MessageId>> { self.get_field(refconfig, "In-Reply-To") + .map(|o| o.map(crate::util::strip_message_delimiters).map(MessageId::from)) } } @@ -182,8 +185,9 @@ impl<'a> MailHeader<'a> { } /// Get a value of the `In-Reply-To` field of the mail file - pub fn get_in_reply_to(&self) -> Result<Option<String>> { + pub fn get_in_reply_to(&self) -> Result<Option<MessageId>> { self.get_field("In-Reply-To") + .map(|o| o.map(crate::util::strip_message_delimiters).map(MessageId::from)) } // TODO: Offer functionality to load and parse mail _once_ from disk, and then use helper object |