Skip to main content

MessageRef

Struct MessageRef 

Source
pub struct MessageRef<'m> { /* private fields */ }
Expand description

A message inside a Message: the root message, or a message nested in a message/rfc822 (or message/global) part. Each message has its own root part, header fields and body lists.

Implementations§

Source§

impl<'m> MessageRef<'m>

Source

pub fn id(&self) -> MessageId

The id of this message: 0 for the root, then nested messages in document order.

Source

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

The root part: the header block of this message and its body.

Source

pub fn container(&self) -> Option<MessagePart<'m>>

The message/rfc822 part holding this message; None for the root message.

Source

pub fn source(&self) -> Source

The buffer this message’s offsets refer to.

Source

pub fn source_bytes(&self) -> &'m [u8] ⓘ

The bytes of the buffer this message’s offsets refer to.

Source

pub fn raw(&self) -> &'m [u8] ⓘ

The bytes of this message, from its first header to its end.

Source

pub fn headers(&self) -> Headers<'m>

The header fields of this message: those of its root part.

Source

pub fn parts(&self) -> impl Iterator<Item = MessagePart<'m>> + use<'m>

The parts of this message (nested messages excluded), in document order.

Source

pub fn text_body( &self, ) -> impl ExactSizeIterator<Item = MessagePart<'m>> + use<'m>

The parts that make up the text body (RFC 8621 textBody): text parts, HTML parts standing in for a missing text version, and inline media, in reading order. MessageRef::text_bodies gives them as text.

Source

pub fn html_body( &self, ) -> impl ExactSizeIterator<Item = MessagePart<'m>> + use<'m>

The parts that make up the HTML body (RFC 8621 htmlBody): HTML parts, text parts standing in for a missing HTML version, and inline media, in reading order. MessageRef::html_bodies gives them as HTML.

Source

pub fn attachments( &self, ) -> impl ExactSizeIterator<Item = MessagePart<'m>> + use<'m>

The attachments (RFC 8621 attachments): the leaf parts, nested messages included, that are not shown as part of the body, plus inline media shown in only one of the two bodies.

Source

pub fn has_attachments(&self) -> bool

Whether a client should offer this message as having attachments: RFC 8621 hasAttachment, true when MessageRef::attachments holds a part without Content-Disposition: inline. Images referenced by cid: count unless they are marked inline; the RFC’s optional exception for embedded images is not applied.

Source

pub fn other_parts(&self) -> impl Iterator<Item = MessagePart<'m>> + use<'m>

The parts of this message that are in no list (issue #107): containers excluded, nested messages excluded. For a message from crate::MessageParser::parse_headers this is the root part.

Source

pub fn text_bodies(&self) -> impl Iterator<Item = Cow<'m, str>> + use<'m>

The text body as text: HTML parts converted, non-text parts skipped.

Source

pub fn html_bodies(&self) -> impl Iterator<Item = Cow<'m, str>> + use<'m>

The HTML body as HTML: text parts converted, non-text parts skipped.

Source

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

The text of the index-th part of the text body.

Source

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

The HTML of the index-th part of the HTML body.

Source

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

A preview of at most max_len bytes of the first text body, else of the first HTML body, without carriage returns; see preview_text.

Source

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

The Content-Type of the root part.

Source

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

The Content-Disposition of the root part.

Source

pub fn attachment_name(&self) -> Option<&'m str>

The attachment name of the root part; see MessagePart::attachment_name.

Source

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

Whether the Content-Type of the root part is type_/subtype (ASCII case-insensitive).

Source

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

The Subject field, RFC 2047 encoded words decoded.

Source

pub fn comments(&self) -> Option<&'m str>

The Comments field, decoded.

Source

pub fn mime_version(&self) -> Option<&'m str>

The MIME-Version field, as written.

Source

pub fn thread_name(&self) -> Option<&'m str>

The subject with reply and forward markers removed; see crate::thread_name.

Source

pub fn from(&self) -> Option<AddressList<'m>>

The From field.

Source

pub fn to(&self) -> Option<AddressList<'m>>

The To field.

Source

pub fn cc(&self) -> Option<AddressList<'m>>

The Cc field.

Source

pub fn bcc(&self) -> Option<AddressList<'m>>

The Bcc field.

Source

pub fn reply_to(&self) -> Option<AddressList<'m>>

The Reply-To field.

Source

pub fn sender(&self) -> Option<AddressList<'m>>

The Sender field.

Source

pub fn all_from(&self) -> impl Iterator<Item = AddressList<'m>> + use<'m>

Every From field, in document order.

Source

pub fn all_to(&self) -> impl Iterator<Item = AddressList<'m>> + use<'m>

Every To field, in document order.

Source

pub fn all_cc(&self) -> impl Iterator<Item = AddressList<'m>> + use<'m>

Every Cc field, in document order.

Source

pub fn all_bcc(&self) -> impl Iterator<Item = AddressList<'m>> + use<'m>

Every Bcc field, in document order.

Source

pub fn resent_to(&self) -> Option<AddressList<'m>>

The Resent-To field.

Source

pub fn resent_from(&self) -> Option<AddressList<'m>>

The Resent-From field.

Source

pub fn resent_cc(&self) -> Option<AddressList<'m>>

The Resent-Cc field.

Source

pub fn resent_bcc(&self) -> Option<AddressList<'m>>

The Resent-Bcc field.

Source

pub fn resent_sender(&self) -> Option<AddressList<'m>>

The Resent-Sender field.

Source

pub fn list_archive(&self) -> Option<AddressList<'m>>

The List-Archive field; see Headers::list_archive.

Source

pub fn list_help(&self) -> Option<AddressList<'m>>

The List-Help field; see Headers::list_help.

Source

pub fn list_id(&self) -> Option<AddressList<'m>>

The List-ID field; see Headers::list_id.

Source

pub fn list_owner(&self) -> Option<AddressList<'m>>

The List-Owner field; see Headers::list_owner.

Source

pub fn list_post(&self) -> Option<AddressList<'m>>

The List-Post field; see Headers::list_post.

Source

pub fn list_subscribe(&self) -> Option<AddressList<'m>>

The List-Subscribe field; see Headers::list_subscribe.

Source

pub fn list_unsubscribe(&self) -> Option<AddressList<'m>>

The List-Unsubscribe field; see Headers::list_unsubscribe.

Source

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

The Date field.

Source

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

The Resent-Date field.

Source

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

The last identifier of the Message-ID field, without angle brackets.

Source

pub fn in_reply_to(&self) -> Option<TextList<'m>>

The identifiers of the In-Reply-To field.

Source

pub fn references(&self) -> Option<TextList<'m>>

The identifiers of the References field.

Source

pub fn resent_message_id(&self) -> Option<TextList<'m>>

The identifiers of the Resent-Message-ID field.

Source

pub fn return_path(&self) -> Option<TextList<'m>>

The Return-Path field; see Headers::return_path.

Source

pub fn keywords(&self) -> Option<TextList<'m>>

The phrases of the Keywords field.

Source

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

The last address of Return-Path, or else the first address of From.

Source

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

The last Received field (the oldest hop).

Source

pub fn all_received(&self) -> impl Iterator<Item = Received<'m>> + use<'m>

Every Received field, in document order (newest hop first).

Trait Implementations§

Source§

impl<'m> Clone for MessageRef<'m>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'m> Copy for MessageRef<'m>

Source§

impl Debug for MessageRef<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'m> Freeze for MessageRef<'m>

§

impl<'m> RefUnwindSafe for MessageRef<'m>

§

impl<'m> Send for MessageRef<'m>

§

impl<'m> Sync for MessageRef<'m>

§

impl<'m> Unpin for MessageRef<'m>

§

impl<'m> UnsafeUnpin for MessageRef<'m>

§

impl<'m> UnwindSafe for MessageRef<'m>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.