Expand description
§structured-email-address
RFC 5321/5322/6531 conformant email address parser, validator, and normalizer.
Unlike existing Rust crates that stop at RFC validation, this crate provides:
- Subaddress extraction:
user+tag@domain→ separateuser,tag,domain - Provider-aware normalization: Gmail dot-stripping, configurable case folding
- PSL domain validation: verify domain against the Public Suffix List
- Anti-homoglyph protection: detect Cyrillic/Latin lookalikes via Unicode skeleton
- Configurable strictness: Strict (5321), Standard (5322), Lax (obs-* allowed)
- Zero-copy parsing: internal spans into the input string
§Quick Start
use structured_email_address::{EmailAddress, Config};
// Simple: parse with defaults
let email: EmailAddress = "user+tag@example.com".parse().unwrap();
assert_eq!(email.local_part(), "user+tag");
assert_eq!(email.tag(), Some("tag"));
assert_eq!(email.domain(), "example.com");
// Configured: Gmail normalization pipeline
let config = Config::builder()
.strip_subaddress()
.dots_gmail_only()
.lowercase_all()
.build();
let email = EmailAddress::parse_with("A.L.I.C.E+promo@Gmail.COM", &config).unwrap();
assert_eq!(email.canonical(), "alice@gmail.com");
assert_eq!(email.tag(), Some("promo"));Structs§
- Config
- Configuration for email address parsing and normalization.
- Config
Builder - Builder for
Config. - Email
Address - A parsed, validated, and normalized email address.
- Error
- Error returned when parsing or validating an email address fails.
Enums§
- Case
Policy - How to handle letter case.
- Domain
Check - How to validate the domain.
- DotPolicy
- How to handle dots in the local part.
- Error
Kind - The specific kind of error that occurred.
- Strictness
- How strictly to validate RFC grammar.
- Subaddress
Policy - Whether to strip +subaddress tags.
Functions§
- confusable_
skeleton - Compute confusable skeleton for anti-homoglyph protection.