Rust

Emails

Partly Rust
Email addresses split, checked and made canonical per provider, and their domains classified as free or disposable.

In Appwrite#

Appwrite runs some of its classes from the Rust crate; the rest are still PHP.

1 PHP classes served from Rust15 still PHP
Rust 1,331 lines (838 code)· PHP 907 lines (477 code)split
PartCodeCommentsBlankTotalFiles
Rust source8383461471,3318
PHP source47727115990715

Comments include doc comments. Each side counts its src/; the PHP side is what the package still has in PHP.

Served from Rust (1)
Utopia\Emails\Email
Still PHP (15)
Utopia\Emails\Canonicals\ProviderUtopia\Emails\Canonicals\Providers\FastmailUtopia\Emails\Canonicals\Providers\GenericUtopia\Emails\Canonicals\Providers\GmailUtopia\Emails\Canonicals\Providers\IcloudUtopia\Emails\Canonicals\Providers\OutlookUtopia\Emails\Canonicals\Providers\ProtonmailUtopia\Emails\Canonicals\Providers\WallaUtopia\Emails\Canonicals\Providers\YahooUtopia\Emails\Canonicals\Providers\YandexUtopia\Emails\Validator\EmailUtopia\Emails\Validator\EmailCorporateUtopia\Emails\Validator\EmailDomainUtopia\Emails\Validator\EmailLocalUtopia\Emails\Validator\EmailNotDisposable

Install#

Shell
cargo add utopia-emails

Overview#

Email addresses: split at the @, checked, made canonical per mail provider, and their domains classified as free or disposable.

PHPRust
Utopia\Emails\EmailEmail
new Email($email)Email::new
get(), getLocal(), getDomain()Email::get, Email::local, Email::domain
isValid(), hasValidLocal()Email::is_valid, Email::has_valid_local
hasValidDomain()Email::has_valid_domain_syntax, then the domain's known suffix (utopia-domains)
isDisposable(), isFree()Lists::is_disposable, Lists::is_on_free_list (isFree() also needs it not disposable)
getCanonical(), isCanonicalSupported(), getCanonicalDomain()Email::canonical, Email::is_canonical_supported, Email::canonical_domain
Email::LOCAL_MAX_LENGTH, DOMAIN_MAX_LENGTHLOCAL_MAX_LENGTH, DOMAIN_MAX_LENGTH
data/free-domains.php, data/disposable-domains.phpLists (Lists::FREE, Lists::DISPOSABLE)
Canonicals\Providers\{Gmail, Outlook, Yahoo, Icloud, Protonmail, Fastmail, Walla, Generic}Provider (PROVIDERS, Provider::GENERIC)

What Email asks of its domain (getProvider(), getSubdomain(), isKnown()) is Utopia\Domains\Domain's, which the extension calls as PHP does, so this crate does not parse domains.

The lists are embedded in the crate (data/*-domains.txt, exported from the PHP package's data/*-domains.php by data/export.php) with hash tables of their lines built at compile time (build.rs), so a lookup allocates nothing and both live in the library's read-only pages, shared by every process. The PHP validators, providers and import task are not ported: Email is.

API#

What utopia_emails exports at its root.