pub struct MessageParser { /* private fields */ }
Expand description

RFC5322/RFC822 message parser.

Implementations§

source§

impl MessageParser

source

pub fn new() -> Self

Create a new builder for a message parser using the default settings.

The default settings are:

  • IANA-registered headers defined in HeaderName are parsed with their corresponding parser.
  • Other headers (HeaderName::Other) are parsed as raw.
source

pub fn with_mime_headers(self) -> Self

Parse all MIME headers:

  • Content-Type
  • Content-Disposition
  • Content-Id
  • Content-Description
  • Content-Location
  • Content-Transfer-Encoding

Adding these MIME headers is required in order to parse message bodies.

source

pub fn with_date_headers(self) -> Self

Parse all Date headers:

  • Date
  • Resent-Date
source

pub fn with_address_headers(self) -> Self

Parse all address headers:

  • From
  • Sender
  • Reply-To
  • To
  • Cc
  • Bcc
  • Resent-From
  • Resent-Sender
  • Resent-To
  • Resent-Cc
  • Resent-Bcc
source

pub fn with_message_ids(self) -> Self

Parse all ID headers:

  • Message-Id
  • In-Reply-To
  • References
  • Resent-Message-Id
source

pub fn with_minimal_headers(self) -> Self

Parse all MIME headers plus:

  • Date
  • From
  • Reply-To
  • To
  • Cc
  • Bcc
source

pub fn without_header(self, header: impl Into<HeaderName<'static>>) -> Self

Remove a custom header parser.

source

pub fn header_text(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as text decoding RFC 2047 encoded words.

source

pub fn header_date(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as a RFC 5322 date.

source

pub fn header_address(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as an address.

source

pub fn header_id(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as an ID.

source

pub fn header_content_type(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as a MIME Content-Type or Content-Disposition type.

source

pub fn header_comma_separated( self, header: impl Into<HeaderName<'static>> ) -> Self

Parse a header as a comma-separated list of values.

source

pub fn header_received(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as a received header.

source

pub fn header_raw(self, header: impl Into<HeaderName<'static>>) -> Self

Parse a header as a raw string, no RFC 2047 decoding is done.

source

pub fn ignore_header(self, header: impl Into<HeaderName<'static>>) -> Self

Ignore and skip parsing a header.

source

pub fn default_header_text(self) -> Self

Parse all other headers as text decoding RFC 2047 encoded words.

source

pub fn default_header_raw(self) -> Self

Parse all other headers as raw strings, no RFC 2047 decoding is done.

source

pub fn default_header_ignore(self) -> Self

Ignore and skip parsing all other headers.

source§

impl MessageParser

source

pub fn parse<'x>( &self, raw_message: impl IntoByteSlice<'x> ) -> Option<Message<'x>>

Parses a byte slice containing the RFC5322 raw message and returns a Message struct.

This function never panics, a best-effort is made to parse the message and if no headers are found None is returned.

source

pub fn parse_headers<'x>( &self, raw_message: impl IntoByteSlice<'x> + 'x ) -> Option<Message<'x>>

Parses a byte slice containing the RFC5322 raw message and returns a Message struct containing only the headers.

Trait Implementations§

source§

impl Clone for MessageParser

source§

fn clone(&self) -> MessageParser

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 MessageParser

source§

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

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

impl Default for MessageParser

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for MessageParser

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for MessageParser

source§

impl StructuralPartialEq for MessageParser

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

§

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

§

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

§

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.