[][src]Trait mail_headers::HeaderKind

pub trait HeaderKind: Clone + Default + 'static {
    type Component: EncodableInHeader + Clone;

    const VALIDATOR: Option<HeaderMapValidator>;
    const MAX_ONE: bool;

    fn name() -> HeaderName;

    fn auto_body<H>(body: H) -> Result<Header<Self>, ComponentCreationError>
    where
        H: HeaderTryInto<Self::Component>
, { ... }
fn body(body: Self::Component) -> Header<Self> { ... } }

Trait representing a mail header.

This is not meant to be implemented by hand.* Use the def_headers macro instead.

Associated Types

type Component: EncodableInHeader + Clone

the component representing the header-field, e.g. Unstructured for Subject

Loading content...

Associated Constants

const VALIDATOR: Option<HeaderMapValidator>

A function which is meant to be called with a reference to the final header map before encoding the headers. It is meant to be used do some of the contextual validations, like e.g. a From header might return a function which checks if the From header has multiple mailboxes and if so checks if there is a Sender header

Calling a contextual validator with a header map not containing a header which it is meant to validate should not cause an error. Only if the header is there and the component is of the expected type and it is invalid in the context an error should be returned.

const MAX_ONE: bool

I true this will assure that the header is at most one time in a header map.

This is similar to VALIDATOR (and can be archived through one) but in difference to any VALIDATOR this is already assured when inserting a header with MAX_ONE set to true in a header map. It exists so that the header map can do, what is most intuitive, replacing insertion for all MAX_ONE headers (like in a normal map) but use adding insertion for all other header (like in a multi map).

Most headers have this set to true.

Loading content...

Required methods

fn name() -> HeaderName

a method returning the header name

Note:

Once const fn is stable this will be changed to a associated constant.

Loading content...

Provided methods

fn auto_body<H>(body: H) -> Result<Header<Self>, ComponentCreationError> where
    H: HeaderTryInto<Self::Component>, 

Creates a Header instance automatically converting given body to the right type.

Error

The type system assure that you can only use it on conversions which are possible on type level, but they can still fail depending on the actual data. For example creating a Email from a string can fail if the string is not a valid email address. This in turn means that creating a From header from a array of strings can fail if one of them is not a valid email address.

fn body(body: Self::Component) -> Header<Self>

Creates a Header instance for this header kind with given body.

Loading content...

Implementors

impl HeaderKind for Bcc[src]

impl HeaderKind for Cc[src]

impl HeaderKind for Comments[src]

impl HeaderKind for ContentDescription[src]

impl HeaderKind for ContentDisposition[src]

impl HeaderKind for ContentId[src]

impl HeaderKind for ContentTransferEncoding[src]

impl HeaderKind for ContentType[src]

impl HeaderKind for Date[src]

impl HeaderKind for InReplyTo[src]

impl HeaderKind for Keywords[src]

impl HeaderKind for MessageId[src]

impl HeaderKind for Received[src]

impl HeaderKind for References[src]

impl HeaderKind for ReplyTo[src]

impl HeaderKind for ResentBcc[src]

impl HeaderKind for ResentCc[src]

impl HeaderKind for ResentDate[src]

impl HeaderKind for ResentFrom[src]

impl HeaderKind for ResentMsgId[src]

impl HeaderKind for ResentSender[src]

impl HeaderKind for ResentTo[src]

impl HeaderKind for ReturnPath[src]

impl HeaderKind for Sender[src]

impl HeaderKind for Subject[src]

impl HeaderKind for _From[src]

impl HeaderKind for _To[src]

Loading content...