Enum Resource

Source
pub enum Resource {
    Source(Source),
    Data(Data),
    EncData(EncData),
}
Expand description

A enum specifying a “resource” for a mail.

A resource represents any kind of actual data. It can be anything from a html body of a mail over a embedded image to a attached spread sheet.

A resource can be specified in 3 ways:

  1. As a source specifying what to get and how to handle it.
  2. Data (and Metadata) representing a resource.
  3. Data (and Metadata) representing a transfer encoded resource.

Normally auto generated content will be provided as Data, embeddings and attachments will be provided as Source (potentially referring to a file on in a file system) and transfer encoded data can not be provided by the user.

When a mail is converted to a encodable mail any resource will be swapped with a version of it which is transfer encoded, so the only way a consumer of this library normally comes in contact with the third variant is by turning a encodable mail back into normal mail.

Variants§

§

Source(Source)

Provide a source which specify what data to use.

This also allows specifying a media type (if not stored with the data and sniffing is not wanted or to unreliable).

Additionally it allows to specify a “file name” which will force the given name to be used instead of inferring it from the IRI or meta data associated with the IRI in “some way” (like file name fild in a database from which the data will loaded).

§

Data(Data)

Provide the data used for the mail bodies content.

This for example could be a png image.

§

EncData(EncData)

Provides a already transfer encoded version of the Data variant.

This can not be created by a consumer of the library and will be created when turning a mail into a transfer encoded mail.

Implementations§

Source§

impl Resource

Source

pub fn load_container<CO>( container: CO, ctx: &impl Context, ) -> ResourceContainerLoadingFuture<CO>

Source§

impl Resource

Source

pub fn plain_text(content: impl Into<String>, ctx: &impl Context) -> Resource

Creates a new text Resource with text/plain; charset=utf-8 media type.

The Context is used to generate a ContentId.

Source

pub fn content_id(&self) -> Option<&ContentId>

Return the content id, if there is any.

Source§

impl Resource

Source

pub fn create_mail(self) -> Mail

Create a Mail instance representing this Resource.

This is not a complete mail, i.e. it will not contain headers like From or To and in many cases the returned Mail instance will be wrapped into other mail instances adding alternative bodies, embedded resources and attachments.

Source

pub fn create_mail_with_disposition( self, disposition_kind: DispositionKind, ) -> Mail

Trait Implementations§

Source§

impl Clone for Resource

Source§

fn clone(&self) -> Resource

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 Resource

Source§

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

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

impl<'de> Deserialize<'de> for Resource

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Resource

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Erased for T