• Stars
    star
    174
  • Rank 217,659 (Top 5 %)
  • Language
    Rust
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The fastest and lightest mail parsing Rust library.

email-parser

The fastest and lightest email parsing Rust library!
This library has no dependency by default (and only a small optional one).

Goal

The goal of this library is to be fully compliant with RFC 5322. However, this library does not intend to support the obsolete syntax because it has been obsolete for 12 years, and it would slow down everything.
This library supports MIME and will support PGP in the future.

Example

let email = Email::parse(
    b"\
    From: Mubelotix <[email protected]>\r\n\
    Subject:Example Email\r\n\
    To: Someone <[email protected]>\r\n\
    Message-id: <[email protected]>\r\n\
    Date: 5 May 2003 18:58:34 +0000\r\n\
    \r\n\
    Hey!\r\n",
)
.unwrap();

assert_eq!(email.subject.unwrap(), "Example Email");
assert_eq!(email.sender.name.unwrap(), vec!["Mubelotix"]);
assert_eq!(email.sender.address.local_part, "mubelotix");
assert_eq!(email.sender.address.domain, "mubelotix.dev");

Pay for what you use

Mails can be elaborated. No matter what you are building, you are certainly not using all of its features.
So why would you pay the parsing cost of header fields you are not using? This library allows you to enable headers you need so that other header values will be parsed as an unstructured header, which is much faster.
By disabling all header value parsing, this library can parse an entire mail twice faster! But don't worry if you need everything enabled; this library is blazing fast anyway!

Zero-Copy (almost)

This library tries to avoid usage of owned Strings as much as possible and is using Cow<str> instead.
Thanks to this method, around 90% of the strings are references.

Benchmarks

This chart shows the time took to parse a single email.

Benchmark

Run these benchmarks by yourself with rustup run nightly cargo bench and rustup run nightly cargo bench --no-default-features.
Tests require a mail.txt file containing a raw mail next to the Cargo.toml.
Some libraries suffer from huge performance variations depending on the content of the mail, so this library is not always the fastest.

License: MIT

More Repositories

1

wasm-extension-template

An easy-to-use template for Rust web extensions. The Rust code is compiled to WASM and ran as a content script.
Shell
189
star
2

admarus

Peer-to-Peer Search Engine for IPFS
Rust
67
star
3

faster-pest

A generator for high-performance Pest parsers, bringing your grammar to the next level
Rust
41
star
4

minecraft-protocol

Highly optimized and lightweight minecraft server written in Rust
Rust
38
star
5

kamilata

Peer-to-Peer Search Engine System
Rust
12
star
6

dkim

Complete Rust DKIM library.
Rust
10
star
7

cli_progress_bar

A Rust crate that allows you to display a progress bar in a terminal.
Rust
8
star
8

dungeon-game

A multiplayer-only game. Native server, wasm client.
Rust
7
star
9

discord-crawler

A lightweight crawler for discord server invite links.
Rust
6
star
10

smtp-server

MDA and MTA supporting TLS.
Rust
5
star
11

webdriver

A lightweight webdriver supporting Firefox and Chrome and running without selenium.
Rust
5
star
12

admarus-blog

3
star
13

tewta

Experimental peer-to-peer social network
Rust
3
star
14

insa-login-rememberer

Rust
3
star
15

wasm-game-lib

A simple and fast game library for Wasm written in Rust.
Rust
3
star
16

gleam-io-automation

A web extension automating gleam.io's giveaways entering (gleam.io bot)
Rust
2
star
17

minecraft-protocol-derive

Procedural macros to make your Rust structs compatible with the Minecraft protocol.
Rust
2
star
18

password-tool

A program between a password manager and a password generator.
Rust
2
star
19

insa-scan

Network scanner for my school's
HTML
2
star
20

mastodon-synchronizer

Rust
2
star
21

calendrier

Rust
2
star
22

gtts

A very small gtts client
Rust
2
star
23

unigui

Rust
1
star
24

sha2-derive

A crate exporting a derivable `Hashable` trait that works with sha2
Rust
1
star
25

gleam_finder_lib

Rust
1
star
26

googleam

Rust
1
star
27

instagram_bot

Rust
1
star
28

tetris_nsi

A school project
Python
1
star
29

minecraft-bot

Rust
1
star
30

webextension-instagram

This is an instagram bot, running in a webextension, running with wasm in Rust!
JavaScript
1
star
31

admarus-census

Rust
1
star