Struct mail_parser::MessageParser
source · pub struct MessageParser { /* private fields */ }
Expand description
RFC5322/RFC822 message parser.
Implementations§
source§impl MessageParser
impl MessageParser
sourcepub fn new() -> Self
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.
sourcepub fn with_mime_headers(self) -> Self
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.
sourcepub fn with_date_headers(self) -> Self
pub fn with_date_headers(self) -> Self
Parse all Date headers:
Date
Resent-Date
sourcepub fn with_address_headers(self) -> Self
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
sourcepub fn with_message_ids(self) -> Self
pub fn with_message_ids(self) -> Self
Parse all ID headers:
Message-Id
In-Reply-To
References
Resent-Message-Id
sourcepub fn with_minimal_headers(self) -> Self
pub fn with_minimal_headers(self) -> Self
Parse all MIME headers plus:
Date
From
Reply-To
To
Cc
Bcc
sourcepub fn without_header(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn without_header(self, header: impl Into<HeaderName<'static>>) -> Self
Remove a custom header parser.
sourcepub fn header_text(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_text(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as text decoding RFC 2047 encoded words.
sourcepub fn header_date(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_date(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as a RFC 5322 date.
sourcepub fn header_address(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_address(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as an address.
sourcepub fn header_id(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_id(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as an ID.
sourcepub fn header_content_type(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_content_type(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as a MIME Content-Type
or Content-Disposition
type.
sourcepub fn header_comma_separated(
self,
header: impl Into<HeaderName<'static>>
) -> Self
pub fn header_comma_separated( self, header: impl Into<HeaderName<'static>> ) -> Self
Parse a header as a comma-separated list of values.
sourcepub fn header_received(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_received(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as a received header.
sourcepub fn header_raw(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn header_raw(self, header: impl Into<HeaderName<'static>>) -> Self
Parse a header as a raw string, no RFC 2047 decoding is done.
sourcepub fn ignore_header(self, header: impl Into<HeaderName<'static>>) -> Self
pub fn ignore_header(self, header: impl Into<HeaderName<'static>>) -> Self
Ignore and skip parsing a header.
sourcepub fn default_header_text(self) -> Self
pub fn default_header_text(self) -> Self
Parse all other headers as text decoding RFC 2047 encoded words.
sourcepub fn default_header_raw(self) -> Self
pub fn default_header_raw(self) -> Self
Parse all other headers as raw strings, no RFC 2047 decoding is done.
sourcepub fn default_header_ignore(self) -> Self
pub fn default_header_ignore(self) -> Self
Ignore and skip parsing all other headers.
source§impl MessageParser
impl MessageParser
sourcepub fn parse<'x>(
&self,
raw_message: impl IntoByteSlice<'x>
) -> Option<Message<'x>>
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.
sourcepub fn parse_headers<'x>(
&self,
raw_message: impl IntoByteSlice<'x> + 'x
) -> Option<Message<'x>>
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
impl Clone for MessageParser
source§fn clone(&self) -> MessageParser
fn clone(&self) -> MessageParser
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MessageParser
impl Debug for MessageParser
source§impl Default for MessageParser
impl Default for MessageParser
source§impl PartialEq for MessageParser
impl PartialEq for MessageParser
source§fn eq(&self, other: &MessageParser) -> bool
fn eq(&self, other: &MessageParser) -> bool
self
and other
values to be equal, and is used
by ==
.