Skip to main content

HeaderForm

Enum HeaderForm 

Source
#[repr(u8)]
pub enum HeaderForm { Raw = 0, Text = 1, Addresses = 2, MessageIds = 3, CommaList = 4, Date = 5, ContentType = 6, Received = 7, Ignore = 8, }
Expand description

How a header value is parsed.

Variants§

§

Raw = 0

The value as written, without leading and trailing whitespace.

§

Text = 1

Unstructured text with RFC 2047 encoded words decoded.

§

Addresses = 2

An address list: mailboxes and groups in document order.

§

MessageIds = 3

A list of message identifiers.

§

CommaList = 4

A comma-separated list of phrases.

§

Date = 5

An RFC 5322 date.

§

ContentType = 6

A Content-Type or Content-Disposition value.

§

Received = 7

A Received trace field.

§

Ignore = 8

Not parsed; the header is kept with an empty value.

Implementations§

Source§

impl HeaderForm

Source

pub fn parse(self, value: &[u8]) -> ParsedValue<'_>

Parses a standalone header value: the bytes after the colon, up to the end of the field (a line break not followed by white space).

use mail_parser::HeaderForm;

let parsed = HeaderForm::Addresses.parse(b" Jane <jane@example.com>, bob@example.com\r\n");
let addresses = parsed.value().as_address().expect("addresses");
assert_eq!(addresses.mailboxes().count(), 2);

let parsed = HeaderForm::Date.parse(b" Sat, 20 Nov 2021 14:22:01 -0800\r\n");
let date = parsed.value().as_datetime().expect("date");
assert_eq!(date.to_timestamp(), 1_637_446_921);

Trait Implementations§

Source§

impl Clone for HeaderForm

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 Copy for HeaderForm

Source§

impl Debug for HeaderForm

Source§

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

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

impl Eq for HeaderForm

Source§

impl Hash for HeaderForm

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for HeaderForm

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HeaderForm

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