Rust

Crate root

Module
What utopia_emails defines at its root.

Contents

use utopia_emails::Canonical;
Rust
pub struct Canonical {
    pub local: Vec<u8>,
    pub domain: Vec<u8>,
}

The canonical form of an address: its local part and domain with a provider's aliases removed.

PHP: the array ['local' => ..., 'domain' => ...] of getCanonical().

use utopia_emails::DomainList;
Rust
pub struct DomainList {
    // private fields
}

A set of domains, matched as PHP's in_array($domain, $list): a loose comparison, so numeric strings compare as numbers ("1e3" matches an entry "1000").

Also implements Default, FromIterator<&'a str>.
use utopia_emails::Email;
Rust
pub struct Email {
    // private fields
}

An address: trimmed, lower-cased (mb_strtolower) and split at its single @. It can hold any bytes, as a PHP string does.

use utopia_emails::Lists;
Rust
pub struct Lists {
    pub free: DomainList,
    pub disposable: DomainList,
}

The free and disposable domain lists.

use utopia_emails::Provider;
Rust
pub struct Provider {
    pub canonical_domain: &'static str,
    pub domains: &'static [&'static str],
    // private fields
}

A mail provider's aliasing rules.

use utopia_emails::Error;
Rust
pub enum Error {
    Parse(Vec<u8>),
    EmptyLocal,
}

Why an address could not be parsed or made canonical.

Rust
pub const DOMAIN_MAX_LENGTH: usize = 253usize;

The most characters allowed after the @.

PHP: Email::DOMAIN_MAX_LENGTH.

Rust
pub const LOCAL_MAX_LENGTH: usize = 64usize;

The most characters allowed before the @.

PHP: Email::LOCAL_MAX_LENGTH.

Rust
pub static PROVIDERS: &[Provider];

The providers Email consults, in order.

PHP: Email::initializeProviders(); Yandex is not among them.