Struct mailparse::MailHeader[][src]

pub struct MailHeader<'a> { /* fields omitted */ }
Expand description

A struct that represents a single header in the message. It holds slices into the raw byte array passed to parse_mail, and so the lifetime of this struct must be contained within the lifetime of the raw input. There are additional accessor functions on this struct to extract the data as Rust strings.

Implementations

Get the name of the header. Note that header names are case-insensitive. Prefer using get_key_ref where possible for better performance.

Get the name of the header, borrowing if it’s ASCII-only. Note that header names are case-insensitive.

Get the value of the header. Any sequences of newlines characters followed by whitespace are collapsed into a single space. In effect, header values wrapped across multiple lines are compacted back into one line, while discarding the extra whitespace required by the MIME format. Additionally, any quoted-printable words in the value are decoded.

Examples

    use mailparse::parse_header;
    let (parsed, _) = parse_header(b"Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?=").unwrap();
    assert_eq!(parsed.get_key(), "Subject");
    assert_eq!(parsed.get_value(), "\u{a1}Hola, se\u{f1}or!");

Get the raw, unparsed value of the header key.

Examples

    use mailparse::parse_header;
    let (parsed, _) = parse_header(b"SuBJect : =?iso-8859-1?Q?=A1Hola,_se=F1or!?=").unwrap();
    assert_eq!(parsed.get_key_raw(), "SuBJect ".as_bytes());

Get the raw, unparsed value of the header value.

Examples

    use mailparse::parse_header;
    let (parsed, _) = parse_header(b"Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?=").unwrap();
    assert_eq!(parsed.get_key(), "Subject");
    assert_eq!(parsed.get_value_raw(), "=?iso-8859-1?Q?=A1Hola,_se=F1or!?=".as_bytes());

Trait Implementations

Custom Debug trait for better formatting and printing of MailHeader items.

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.