# disposable-emails
Fast, zero-allocation disposable / temporary email domain detection for Rust.
Tells you whether an email address — or just its domain — belongs to a
disposable / temp-mail provider (Mailinator, Guerrilla Mail, 10MinuteMail, and
~72,000 others). Useful for blocking throwaway inboxes from sign-up flows,
free-trial farming, and per-account abuse.
```toml
[dependencies]
disposable-emails = "0.1"
```
```rust
use disposable_emails::{is_disposable_email, is_disposable_domain};
assert!(is_disposable_email("someone@mailinator.com"));
assert!(is_disposable_domain("guerrillamail.com"));
assert!(!is_disposable_email("jeff@gmail.com"));
```
## Why it's cheap
The ~72k-domain blocklist is compiled into a **sorted `&'static [&'static str]`**
by the build script. There is:
- **no heap allocation** — the list lives in the binary's read-only segment;
no `HashSet` is built,
- **no startup cost** — nothing is parsed or loaded at runtime,
- an `O(log n)` binary-search lookup (~17 comparisons).
The only per-call allocation is a small lowercase copy of the *input* domain.
## API
| `is_disposable_email(&str) -> bool` | Domain of the address is disposable. Malformed input → `false`. |
| `is_disposable_domain(&str) -> bool` | The domain is disposable. Case-insensitive; tolerates a trailing `.`. |
| `domain_count() -> usize` | Size of the embedded blocklist. |
## The blocklist
`domains.txt` is a vendored copy of the community-maintained
[`disposable`](https://github.com/disposable/disposable-email-domains)
aggregate. To refresh it, replace that file and rebuild — the build script
re-sorts and de-duplicates.
`no_std` is not required to be off — the crate is `#![forbid(unsafe_code)]` and
depends only on `core`/`alloc`-level std.
## Licence
Dual-licensed under either of [Apache-2.0](LICENSE-APACHE) or
[MIT](LICENSE-MIT), at your option.