1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/
//! Fast and robust e-mail parsing.
//!
//! A [`MessageParser`] turns the bytes of an RFC 5322 message into a
//! read-only [`Message`]: the raw bytes plus a flat, index-based store of
//! every nested message, MIME part and header field. Everything is read
//! through small `Copy` views ([`MessageRef`], [`MessagePart`], [`Header`],
//! [`HeaderValue`], ...), and bodies are decoded on access.
//!
//! ```
//! use mail_parser::MessageParser;
//!
//! let raw = b"From: Ann <ann@example.com>\r\nSubject: Hi\r\n\r\nHello!\r\n";
//! let message = MessageParser::new().parse(raw).expect("message");
//! assert_eq!(message.subject(), Some("Hi"));
//! assert_eq!(message.body_text(0).as_deref(), Some("Hello!\r\n"));
//! ```
//!
//! - Parsing: [`MessageParser::parse`], [`MessageParser::parse_owned`],
//! [`MessageParser::parse_headers`], and [`MessageParser::parse_with`]
//! with [`MessageBuffers`] to reuse storage from one message to the next.
//! - Structure: [`Message::parts`] and [`Message::messages`] in document
//! order, [`MessagePart::children`], [`MessagePart::nested`], the RFC 8621
//! body lists ([`MessageRef::text_body`], [`MessageRef::html_body`],
//! [`MessageRef::attachments`]) and MIME boundaries
//! ([`MessagePart::boundary`], [`Message::part_by_boundary`]).
//! - Bodies: [`MessagePart::decoded`], [`MessagePart::text`],
//! [`MessagePart::text_prefix`] and [`MessagePart::decoded_len`];
//! [`MessagePart::decoded_checked`] and [`MessagePart::text_checked`]
//! also report decoding problems.
//! - Header fields: [`Headers`] with typed getters, [`Header::raw_name`]
//! and [`Header::raw_value`] as written, [`Header::parse_as`] to parse a
//! field in another form, and [`HeaderForm::parse`] for values on their
//! own.
//! - Mailboxes: [`mailbox::mbox`] and [`mailbox::maildir`].
//! - Utilities: [`DateTime`], [`thread_name`], [`html_to_text`],
//! [`text_to_html`], [`preview_text`], [`Charset`] and the other
//! [`decoders`].
//!
//! Parsing never fails on malformed input: damaged structure is reported
//! by [`MessagePart::flags`], malformed encodings by the checked decoding
//! methods. The `full_encoding` feature adds the multi-byte charsets
//! (through `encoding_rs`), and the `serde` feature serializes messages.
;
pub use ;
pub use ;
pub use ;
pub use ;
pub use MessageParser;
pub use ;
pub use ;
/// Declared Content-Transfer-Encoding of a part. The numeric values (0, 1,
/// 2) are stable.