Skip to content

Commit ea23e47

Browse files
committed
v0.3.0: Improved API.
1 parent 3c14e77 commit ea23e47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+6200
-5588
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "mail-parser"
33
description = "Fast and robust e-mail parsing library for Rust"
4-
version = "0.2.2"
4+
version = "0.3.0"
55
edition = "2018"
66
authors = [ "Stalwart Labs <hello@stalw.art>"]
77
license = "Apache-2.0 OR MIT"

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Twitter Follow](https://img.shields.io/twitter/follow/stalwartlabs?style=social)](https://twitter.com/stalwartlabs)
88

99
_mail-parser_ is an **e-mail parsing library** written in Rust that fully conforms to the Internet Message Format standard (_RFC 5322_), the
10-
Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as other [internet messaging RFCs](#conformed-rfcs).
10+
Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as many other [internet messaging RFCs](#conformed-rfcs).
1111

1212
It also supports decoding messages in [41 different character sets](#supported-character-sets) including obsolete formats such as UTF-7.
1313
All Unicode (UTF-*) and single-byte character sets are handled internally by the library while support for legacy multi-byte encodings of Chinese
@@ -72,19 +72,19 @@ Performance and memory safety were two important factors while designing _mail-p
7272
)
7373
.as_bytes();
7474

75-
let message = Message::parse(input);
75+
let message = Message::parse(input).unwrap();
7676

7777
// Parses addresses (including comments), lists and groups
7878
assert_eq!(
7979
message.get_from(),
80-
&Address::Address(Addr {
80+
&HeaderValue::Address(Addr {
8181
name: Some("Art Vandelay (Vandelay Industries)".into()),
8282
address: Some("art@vandelay.com".into())
8383
})
8484
);
8585
assert_eq!(
8686
message.get_to(),
87-
&Address::GroupList(vec![
87+
&HeaderValue::GroupList(vec![
8888
Group {
8989
name: Some("Colleagues".into()),
9090
addresses: vec![Addr {
@@ -169,8 +169,6 @@ Performance and memory safety were two important factors while designing _mail-p
169169
// Full RFC2231 support for continuations and character sets
170170
assert_eq!(
171171
nested_attachment
172-
.get_header()
173-
.unwrap()
174172
.get_content_type()
175173
.unwrap()
176174
.get_attribute("name")
@@ -219,11 +217,15 @@ and, to run the benchmarks:
219217
- [RFC 2048 - Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures](https://datatracker.ietf.org/doc/html/rfc2048)
220218
- [RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples](https://datatracker.ietf.org/doc/html/rfc2049)
221219
- [RFC 2231 - MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations](https://datatracker.ietf.org/doc/html/rfc2231)
220+
- [RFC 2557 - MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)](https://datatracker.ietf.org/doc/html/rfc2557)
222221
- [RFC 2183 - Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field](https://datatracker.ietf.org/doc/html/rfc2183)
222+
- [RFC 2392 - Content-ID and Message-ID Uniform Resource Locators](https://datatracker.ietf.org/doc/html/rfc2392)
223+
- [RFC 3282 - Content Language Headers](https://datatracker.ietf.org/doc/html/rfc3282)
223224
- [RFC 6532 - Internationalized Email Headers](https://datatracker.ietf.org/doc/html/rfc6532)
224225
- [RFC 2152 - UTF-7 - A Mail-Safe Transformation Format of Unicode](https://datatracker.ietf.org/doc/html/rfc2152)
225226
- [RFC 2369 - The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields](https://datatracker.ietf.org/doc/html/rfc2369)
226227
- [RFC 2919 - List-Id: A Structured Field and Namespace for the Identification of Mailing Lists](https://datatracker.ietf.org/doc/html/rfc2919)
228+
- [RFC 3339 - Date and Time on the Internet: Timestamps](https://datatracker.ietf.org/doc/html/rfc3339)
227229
- [RFC 8621 - The JSON Meta Application Protocol (JMAP) for Mail (Section 4.1.4)](https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.4)
228230

229231
## Supported Character Sets

examples/email_to_json_and_yaml.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* except according to those terms.
1010
*/
1111

12-
use mail_parser::{Addr, Address, BodyPart, Group, Message, MessagePart, MimeFieldGet};
12+
use mail_parser::*;
1313

1414
fn main() {
1515
let input = concat!(
@@ -49,19 +49,19 @@ fn main() {
4949
)
5050
.as_bytes();
5151

52-
let message = Message::parse(input);
52+
let message = Message::parse(input).unwrap();
5353

5454
// Parses addresses (including comments), lists and groups
5555
assert_eq!(
5656
message.get_from(),
57-
&Address::Address(Addr {
57+
&HeaderValue::Address(Addr {
5858
name: Some("Art Vandelay (Vandelay Industries)".into()),
5959
address: Some("art@vandelay.com".into())
6060
})
6161
);
6262
assert_eq!(
6363
message.get_to(),
64-
&Address::GroupList(vec![
64+
&HeaderValue::GroupList(vec![
6565
Group {
6666
name: Some("Colleagues".into()),
6767
addresses: vec![Addr {
@@ -146,8 +146,6 @@ fn main() {
146146
// Full RFC2231 support for continuations and character sets
147147
assert_eq!(
148148
nested_attachment
149-
.get_header()
150-
.unwrap()
151149
.get_content_type()
152150
.unwrap()
153151
.get_attribute("name")

0 commit comments

Comments
 (0)