Struct EncodableMail

Source
pub struct EncodableMail(/* private fields */);
Expand description

a mail with all contained futures resolved, so that it can be encoded

Implementations§

Source§

impl EncodableMail

Source

pub fn encode(&self, encoder: &mut EncodingBuffer) -> Result<(), MailError>

Encode the mail using the given encoding buffer.

After encoding succeeded the buffer should contain a fully encoded mail including all attachments, embedded images alternate bodies etc.

§Error

This can fail for a large number of reasons, e.g. some input can not be encoded with the given mail type or some headers/resources breack the mails hard line length limit.

Source

pub fn encode_into_bytes( &self, mail_type: MailType, ) -> Result<Vec<u8>, MailError>

A wrapper for encode which will create a buffer, enocde the mail and then returns the buffers content.

Methods from Deref<Target = Mail>§

Source

pub fn has_multipart_body(&self) -> bool

Returns true if the body of the mail is a multipart body.

Source

pub fn headers(&self) -> &HeaderMap

Returns a reference to the currently set headers.

Note that some headers namely Content-Transfer-Encoding as well as Content-Type for singlepart mails are derived from the content and should not be set. If done so they are either ignored or an error is caused by them in other parts of the crate (like e.g. encoding). Also Date is auto-generated if not set and it is needed.

Source

pub fn body(&self) -> &MailBody

Returns a reference to the body/bodies.

Source

pub fn generally_validate_mail(&self) -> Result<(), MailError>

Validate the mail.

This will mainly validate the mail headers by

  • checking if no ContentTransferHeader is given
  • (for mails with multipart bodies) checking if the content type is a multipart media type
  • (for mail with non-multipart bodies) check if there is no content type header (as the content type header will be derived from he Resource)
  • running all header validators (with use_contextual_validators) this also checks for “max one” consistency (see HeaderMap’s documentation for more details)
  • doing this recursively with all contained mails

Note that this will be called by into_encodable_mail, therefor it is normally not required to call this function by yourself.

Be aware that this does a general validation applicable to both the top level headers and headers from multipart mail sub bodies. This means it e.g. doesn’t check if there are any of the required headers (Date and From).

Trait Implementations§

Source§

impl Clone for EncodableMail

Source§

fn clone(&self) -> EncodableMail

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 Debug for EncodableMail

Source§

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

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

impl Deref for EncodableMail

Source§

type Target = Mail

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Into<Mail> for EncodableMail

Source§

fn into(self) -> Mail

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

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> HeaderTryFrom<T> for T

Source§

impl<F, T> HeaderTryInto<T> for F
where T: HeaderTryFrom<F>,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> Erased for T