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>

source

pub fn root_part(&self) -> &MessagePart<'x>

Returns the root message part

source

pub fn header( &self, header: impl Into<HeaderName<'x>> ) -> Option<&HeaderValue<'_>>

Returns a parsed header.

source

pub fn remove_header( &mut self, header: impl Into<HeaderName<'x>> ) -> Option<HeaderValue<'_>>

Removed a parsed header and returns its value.

source

pub fn header_raw(&self, header: impl Into<HeaderName<'x>>) -> Option<&str>

Returns the raw header.

source

pub fn header_as( &self, header: impl Into<HeaderName<'x>>, form: HeaderForm ) -> Vec<HeaderValue<'_>>

source

pub fn headers(&self) -> &[Header<'_>]

Returns an iterator over the RFC headers of this message.

source

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.

source

pub fn headers_raw(&self) -> impl Iterator<Item = (&str, &str)>

Returns all headers in raw format

source

pub fn raw_message(&self) -> &[u8]

Returns the raw message

source

pub fn bcc<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the BCC header field

source

pub fn cc<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the CC header field

source

pub fn comments(&self) -> &HeaderValue<'_>

Returns all Comments header fields

source

pub fn date(&self) -> Option<&DateTime>

Returns the Date header field

source

pub fn from<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the From header field

source

pub fn in_reply_to(&self) -> &HeaderValue<'_>

Returns all In-Reply-To header fields

source

pub fn keywords(&self) -> &HeaderValue<'_>

Returns all Keywords header fields

source

pub fn list_archive(&self) -> &HeaderValue<'_>

Returns the List-Archive header field

source

pub fn list_help(&self) -> &HeaderValue<'_>

Returns the List-Help header field

source

pub fn list_id(&self) -> &HeaderValue<'_>

Returns the List-ID header field

source

pub fn list_owner(&self) -> &HeaderValue<'_>

Returns the List-Owner header field

source

pub fn list_post(&self) -> &HeaderValue<'_>

Returns the List-Post header field

source

pub fn list_subscribe(&self) -> &HeaderValue<'_>

Returns the List-Subscribe header field

source

pub fn list_unsubscribe(&self) -> &HeaderValue<'_>

Returns the List-Unsubscribe header field

source

pub fn message_id(&self) -> Option<&str>

Returns the Message-ID header field

source

pub fn mime_version(&self) -> &HeaderValue<'_>

Returns the MIME-Version header field

source

pub fn received(&self) -> Option<&Received<'_>>

Returns the first Received header field

source

pub fn references(&self) -> &HeaderValue<'_>

Returns all References header fields

source

pub fn reply_to<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Reply-To header field

source

pub fn resent_bcc<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Resent-BCC header field

source

pub fn resent_cc<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Resent-CC header field

source

pub fn resent_date(&self) -> &HeaderValue<'_>

Returns all Resent-Date header fields

source

pub fn resent_from<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Resent-From header field

source

pub fn resent_message_id(&self) -> &HeaderValue<'_>

Returns all Resent-Message-ID header fields

source

pub fn resent_sender<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Sender header field

source

pub fn resent_to<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Resent-To header field

source

pub fn return_path(&self) -> &HeaderValue<'_>

Returns all Return-Path header fields

source

pub fn return_address(&self) -> Option<&str>

Returns the return address from either the Return-Path or From header fields

source

pub fn sender<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the Sender header field

source

pub fn subject(&self) -> Option<&str>

Returns the Subject header field

source

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)

source

pub fn to<'y: 'x>(&'y self) -> Option<&Address<'x>>

Returns the To header field

source

pub fn body_preview(&self, preview_len: usize) -> Option<Cow<'x, str>>

Returns a preview of the message body

source

pub fn body_html(&'x self, pos: usize) -> Option<Cow<'x, str>>

Returns a message body part as text/plain

source

pub fn body_text(&'x self, pos: usize) -> Option<Cow<'x, str>>

Returns a message body part as text/plain

source

pub fn part(&self, pos: usize) -> Option<&MessagePart<'_>>

Returns a message part by position

source

pub fn html_part(&self, pos: usize) -> Option<&MessagePart<'_>>

Returns an inline HTML body part by position

source

pub fn text_part(&self, pos: usize) -> Option<&MessagePart<'_>>

Returns an inline text body part by position

source

pub fn attachment(&self, pos: usize) -> Option<&MessagePart<'x>>

Returns an attacment by position

source

pub fn text_body_count(&self) -> usize

Returns the number of plain text body parts

source

pub fn html_body_count(&self) -> usize

Returns the number of HTML body parts

source

pub fn attachment_count(&self) -> usize

Returns the number of attachments

source

pub fn text_bodies(&'x self) -> BodyPartIterator<'x>

Returns an Interator over the text body parts

source

pub fn html_bodies(&'x self) -> BodyPartIterator<'x>

Returns an Interator over the HTML body parts

source

pub fn attachments(&'x self) -> AttachmentIterator<'x>

Returns an Interator over the attachments

source

pub fn into_owned(self) -> Message<'static>

Returns an owned version of the message

source§

impl<'x> Message<'x>

source

pub fn is_empty(&self) -> bool

Returns false if at least one header field was successfully parsed.

Trait Implementations§

source§

impl<'x> Clone for Message<'x>

source§

fn clone(&self) -> Message<'x>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'x> Debug for Message<'x>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'x> Default for Message<'x>

source§

fn default() -> Message<'x>

Returns the “default value” for a type. Read more
source§

impl<'x> MimeHeaders<'x> for Message<'x>

source§

fn content_description(&self) -> Option<&str>

Returns the Content-Description field
source§

fn content_disposition(&self) -> Option<&ContentType<'_>>

Returns the Content-Disposition field
source§

fn content_id(&self) -> Option<&str>

Returns the Content-ID field
source§

fn content_transfer_encoding(&self) -> Option<&str>

Returns the Content-Encoding field
source§

fn content_type(&self) -> Option<&ContentType<'_>>

Returns the Content-Type field
source§

fn content_language(&self) -> &HeaderValue<'_>

Returns the Content-Language field
source§

fn content_location(&self) -> Option<&str>

Returns the Content-Location field
source§

fn attachment_name(&self) -> Option<&str>

Returns the attachment name, if any.
source§

fn is_content_type(&self, type_: &str, subtype: &str) -> bool

source§

impl<'x> PartialEq for Message<'x>

source§

fn eq(&self, other: &Message<'x>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'x> TryInto<Message<'x>> for &'x [u8]

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<Message<'x>, Self::Error>

Performs the conversion.
source§

impl<'x> StructuralPartialEq for Message<'x>

Auto Trait Implementations§

§

impl<'x> Freeze for Message<'x>

§

impl<'x> RefUnwindSafe for Message<'x>

§

impl<'x> Send for Message<'x>

§

impl<'x> Sync for Message<'x>

§

impl<'x> Unpin for Message<'x>

§

impl<'x> UnwindSafe for Message<'x>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.