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: &'x (impl AsRef<[u8]> + ?Sized),
) -> Option<Message<'x>>
pub fn parse<'x>( &self, raw_message: &'x (impl AsRef<[u8]> + ?Sized), ) -> 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.
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 more