Struct mail_parser::Message
source · pub struct Message<'x> {
pub html_body: Vec<MessagePartId>,
pub text_body: Vec<MessagePartId>,
pub attachments: Vec<MessagePartId>,
pub parts: Vec<MessagePart<'x>>,
pub raw_message: Cow<'x, [u8]>,
}
Expand description
An RFC5322/RFC822 message.
Fields§
§html_body: Vec<MessagePartId>
§text_body: Vec<MessagePartId>
§attachments: Vec<MessagePartId>
§parts: Vec<MessagePart<'x>>
§raw_message: Cow<'x, [u8]>
Implementations§
source§impl<'x> Message<'x>
impl<'x> Message<'x>
sourcepub fn root_part(&self) -> &MessagePart<'x>
pub fn root_part(&self) -> &MessagePart<'x>
Returns the root message part
sourcepub fn header(
&self,
header: impl Into<HeaderName<'x>>
) -> Option<&HeaderValue<'_>>
pub fn header( &self, header: impl Into<HeaderName<'x>> ) -> Option<&HeaderValue<'_>>
Returns a parsed header.
sourcepub fn remove_header(
&mut self,
header: impl Into<HeaderName<'x>>
) -> Option<HeaderValue<'_>>
pub fn remove_header( &mut self, header: impl Into<HeaderName<'x>> ) -> Option<HeaderValue<'_>>
Removed a parsed header and returns its value.
sourcepub fn header_raw(&self, header: impl Into<HeaderName<'x>>) -> Option<&str>
pub fn header_raw(&self, header: impl Into<HeaderName<'x>>) -> Option<&str>
Returns the raw header.
pub fn header_as( &self, header: impl Into<HeaderName<'x>>, form: HeaderForm ) -> Vec<HeaderValue<'_>>
sourcepub fn headers(&self) -> &[Header<'_>]
pub fn headers(&self) -> &[Header<'_>]
Returns an iterator over the RFC headers of this message.
sourcepub fn header_values<'y: 'x>(
&'y self,
name: impl Into<HeaderName<'x>>
) -> impl Iterator<Item = &HeaderValue<'x>>
pub fn header_values<'y: 'x>( &'y self, name: impl Into<HeaderName<'x>> ) -> impl Iterator<Item = &HeaderValue<'x>>
Returns an iterator over the matching RFC headers of this message.
sourcepub fn headers_raw(&self) -> impl Iterator<Item = (&str, &str)>
pub fn headers_raw(&self) -> impl Iterator<Item = (&str, &str)>
Returns all headers in raw format
sourcepub fn raw_message(&self) -> &[u8] ⓘ
pub fn raw_message(&self) -> &[u8] ⓘ
Returns the raw message
sourcepub fn comments(&self) -> &HeaderValue<'_>
pub fn comments(&self) -> &HeaderValue<'_>
Returns all Comments header fields
sourcepub fn in_reply_to(&self) -> &HeaderValue<'_>
pub fn in_reply_to(&self) -> &HeaderValue<'_>
Returns all In-Reply-To header fields
sourcepub fn keywords(&self) -> &HeaderValue<'_>
pub fn keywords(&self) -> &HeaderValue<'_>
Returns all Keywords header fields
sourcepub fn list_archive(&self) -> &HeaderValue<'_>
pub fn list_archive(&self) -> &HeaderValue<'_>
Returns the List-Archive header field
sourcepub fn list_help(&self) -> &HeaderValue<'_>
pub fn list_help(&self) -> &HeaderValue<'_>
Returns the List-Help header field
sourcepub fn list_id(&self) -> &HeaderValue<'_>
pub fn list_id(&self) -> &HeaderValue<'_>
Returns the List-ID header field
sourcepub fn list_owner(&self) -> &HeaderValue<'_>
pub fn list_owner(&self) -> &HeaderValue<'_>
Returns the List-Owner header field
sourcepub fn list_post(&self) -> &HeaderValue<'_>
pub fn list_post(&self) -> &HeaderValue<'_>
Returns the List-Post header field
sourcepub fn list_subscribe(&self) -> &HeaderValue<'_>
pub fn list_subscribe(&self) -> &HeaderValue<'_>
Returns the List-Subscribe header field
sourcepub fn list_unsubscribe(&self) -> &HeaderValue<'_>
pub fn list_unsubscribe(&self) -> &HeaderValue<'_>
Returns the List-Unsubscribe header field
sourcepub fn message_id(&self) -> Option<&str>
pub fn message_id(&self) -> Option<&str>
Returns the Message-ID header field
sourcepub fn mime_version(&self) -> &HeaderValue<'_>
pub fn mime_version(&self) -> &HeaderValue<'_>
Returns the MIME-Version header field
sourcepub fn references(&self) -> &HeaderValue<'_>
pub fn references(&self) -> &HeaderValue<'_>
Returns all References header fields
sourcepub fn resent_bcc<'y: 'x>(&'y self) -> Option<&Address<'x>>
pub fn resent_bcc<'y: 'x>(&'y self) -> Option<&Address<'x>>
Returns the Resent-BCC header field
sourcepub fn resent_date(&self) -> &HeaderValue<'_>
pub fn resent_date(&self) -> &HeaderValue<'_>
Returns all Resent-Date header fields
sourcepub fn resent_from<'y: 'x>(&'y self) -> Option<&Address<'x>>
pub fn resent_from<'y: 'x>(&'y self) -> Option<&Address<'x>>
Returns the Resent-From header field
sourcepub fn resent_message_id(&self) -> &HeaderValue<'_>
pub fn resent_message_id(&self) -> &HeaderValue<'_>
Returns all Resent-Message-ID header fields
sourcepub fn resent_sender<'y: 'x>(&'y self) -> Option<&Address<'x>>
pub fn resent_sender<'y: 'x>(&'y self) -> Option<&Address<'x>>
Returns the Sender header field
sourcepub fn return_path(&self) -> &HeaderValue<'_>
pub fn return_path(&self) -> &HeaderValue<'_>
Returns all Return-Path header fields
sourcepub fn return_address(&self) -> Option<&str>
pub fn return_address(&self) -> Option<&str>
Returns the return address from either the Return-Path or From header fields
sourcepub fn thread_name(&self) -> Option<&str>
pub fn thread_name(&self) -> Option<&str>
Returns the message thread name or ‘base subject’ as defined in RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)
sourcepub fn body_preview(&self, preview_len: usize) -> Option<Cow<'x, str>>
pub fn body_preview(&self, preview_len: usize) -> Option<Cow<'x, str>>
Returns a preview of the message body
sourcepub fn body_html(&'x self, pos: usize) -> Option<Cow<'x, str>>
pub fn body_html(&'x self, pos: usize) -> Option<Cow<'x, str>>
Returns a message body part as text/plain
sourcepub fn body_text(&'x self, pos: usize) -> Option<Cow<'x, str>>
pub fn body_text(&'x self, pos: usize) -> Option<Cow<'x, str>>
Returns a message body part as text/plain
sourcepub fn part(&self, pos: usize) -> Option<&MessagePart<'_>>
pub fn part(&self, pos: usize) -> Option<&MessagePart<'_>>
Returns a message part by position
sourcepub fn html_part(&self, pos: usize) -> Option<&MessagePart<'_>>
pub fn html_part(&self, pos: usize) -> Option<&MessagePart<'_>>
Returns an inline HTML body part by position
sourcepub fn text_part(&self, pos: usize) -> Option<&MessagePart<'_>>
pub fn text_part(&self, pos: usize) -> Option<&MessagePart<'_>>
Returns an inline text body part by position
sourcepub fn attachment(&self, pos: usize) -> Option<&MessagePart<'x>>
pub fn attachment(&self, pos: usize) -> Option<&MessagePart<'x>>
Returns an attacment by position
sourcepub fn text_body_count(&self) -> usize
pub fn text_body_count(&self) -> usize
Returns the number of plain text body parts
sourcepub fn html_body_count(&self) -> usize
pub fn html_body_count(&self) -> usize
Returns the number of HTML body parts
sourcepub fn attachment_count(&self) -> usize
pub fn attachment_count(&self) -> usize
Returns the number of attachments
sourcepub fn text_bodies(&'x self) -> BodyPartIterator<'x>
pub fn text_bodies(&'x self) -> BodyPartIterator<'x>
Returns an Interator over the text body parts
sourcepub fn html_bodies(&'x self) -> BodyPartIterator<'x>
pub fn html_bodies(&'x self) -> BodyPartIterator<'x>
Returns an Interator over the HTML body parts
sourcepub fn attachments(&'x self) -> AttachmentIterator<'x>
pub fn attachments(&'x self) -> AttachmentIterator<'x>
Returns an Interator over the attachments
sourcepub fn into_owned(self) -> Message<'static>
pub fn into_owned(self) -> Message<'static>
Returns an owned version of the message