Struct 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<'x>>

Returns a parsed header.

Source

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

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<'x>]

Returns an iterator over the RFC headers of this message.

Source

pub fn header_values( &self, name: impl Into<HeaderName<'x>>, ) -> impl Iterator<Item = &HeaderValue<'x>> + Sync + Send

Returns an iterator over the matching RFC headers of this message.

Source

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

Returns all headers in raw format

Source

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

Returns the raw message

Source

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

Returns the BCC header field

Source

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

Returns the CC header field

Source

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

Returns all Comments header fields

Source

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

Returns the Date header field

Source

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

Returns the From header field

Source

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

Returns all In-Reply-To header fields

Source

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

Returns all Keywords header fields

Source

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

Returns the List-Archive header field

Source

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

Returns the List-Help header field

Source

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

Returns the List-ID header field

Source

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

Returns the List-Owner header field

Source

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

Returns the List-Post header field

Source

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

Returns the List-Subscribe header field

Source

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

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<'x>

Returns the MIME-Version header field

Source

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

Returns the first Received header field

Source

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

Returns all References header fields

Source

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

Returns the Reply-To header field

Source

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

Returns the Resent-BCC header field

Source

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

Returns the Resent-CC header field

Source

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

Returns all Resent-Date header fields

Source

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

Returns the Resent-From header field

Source

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

Returns all Resent-Message-ID header fields

Source

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

Returns the Sender header field

Source

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

Returns the Resent-To header field

Source

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

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(&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(&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: u32) -> Option<&MessagePart<'x>>

Returns a message part by position

Source

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

Returns an inline HTML body part by position

Source

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

Returns an inline text body part by position

Source

pub fn attachment(&self, pos: u32) -> 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( &self, ) -> impl Iterator<Item = &MessagePart<'_>> + Sync + Send

Returns an Interator over the text body parts

Source

pub fn html_bodies( &self, ) -> impl Iterator<Item = &MessagePart<'_>> + Sync + Send

Returns an Interator over the HTML body parts

Source

pub fn attachments( &self, ) -> impl Iterator<Item = &MessagePart<'_>> + Sync + Send

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<'x>>

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<'x>>

Returns the Content-Type field
Source§

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

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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]

Source§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.