Struct Email

Source
pub struct Email<'a> {
Show 16 fields pub body: Option<Cow<'a, str>>, pub from: Vec<Mailbox<'a>>, pub sender: Mailbox<'a>, pub subject: Option<Cow<'a, str>>, pub date: DateTime, pub to: Option<Vec<Address<'a>>>, pub cc: Option<Vec<Address<'a>>>, pub bcc: Option<Vec<Address<'a>>>, pub message_id: Option<(Cow<'a, str>, Cow<'a, str>)>, pub in_reply_to: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>, pub references: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>, pub reply_to: Option<Vec<Address<'a>>>, pub comments: Vec<Cow<'a, str>>, pub keywords: Vec<Vec<Cow<'a, str>>>, pub trace: Vec<(Option<Option<EmailAddress<'a>>>, Vec<(Vec<ReceivedToken<'a>>, DateTime)>, Vec<TraceField<'a>>)>, pub unknown_fields: Vec<(&'a str, Cow<'a, str>)>,
}
Expand description

A struct representing a valid RFC 5322 message.

§Example

let email = Email::parse(
    b"\
    From: Mubelotix <mubelotix@mubelotix.dev>\r\n\
    Subject:Example Email\r\n\
    To: Someone <example@example.com>\r\n\
    Message-id: <6546518945@mubelotix.dev>\r\n\
    Date: 5 May 2003 18:58:34 +0000\r\n\
    \r\n\
    Hey!\r\n",
)
.unwrap();

assert_eq!(email.subject.unwrap(), "Example Email");
assert_eq!(email.sender.name.unwrap(), vec!["Mubelotix"]);
assert_eq!(email.sender.address.local_part, "mubelotix");
assert_eq!(email.sender.address.domain, "mubelotix.dev");

Fields§

§body: Option<Cow<'a, str>>

The ASCII text of the body.

§from: Vec<Mailbox<'a>>

The list of authors of the message.
It’s not the identity of the sender. See the sender field.

§sender: Mailbox<'a>

The mailbox of the agent responsible for the actual transmission of the message.
Do not mix up with the from field that contains the list of authors.
When there is only one author, this field can be omitted, and its value is inferred. Otherwise, an explicit value is required.

§subject: Option<Cow<'a, str>>

A short optional string identifying the topic of the message.

§date: DateTime

The date and time at which the sender of the message indicated that the message was complete and ready to enter the mail delivery system. For instance, this might be the time that a user pushes the “send” or “submit” button in an application program.

§to: Option<Vec<Address<'a>>>§cc: Option<Vec<Address<'a>>>§bcc: Option<Vec<Address<'a>>>§message_id: Option<(Cow<'a, str>, Cow<'a, str>)>§in_reply_to: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>§references: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>§reply_to: Option<Vec<Address<'a>>>§comments: Vec<Cow<'a, str>>§keywords: Vec<Vec<Cow<'a, str>>>§trace: Vec<(Option<Option<EmailAddress<'a>>>, Vec<(Vec<ReceivedToken<'a>>, DateTime)>, Vec<TraceField<'a>>)>§unknown_fields: Vec<(&'a str, Cow<'a, str>)>

The list of unrecognized fields.
Each field is stored as a (name, value) tuple.

Implementations§

Source§

impl<'a> Email<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<Email<'a>, Error>

Parse an email.

Trait Implementations§

Source§

impl<'a> Debug for Email<'a>

Source§

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

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

impl<'a> TryFrom<&'a [u8]> for Email<'a>

Source§

type Error = Error

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

fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for Email<'a>

§

impl<'a> RefUnwindSafe for Email<'a>

§

impl<'a> Send for Email<'a>

§

impl<'a> Sync for Email<'a>

§

impl<'a> Unpin for Email<'a>

§

impl<'a> UnwindSafe for Email<'a>

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