tld 2.40.0

Top Level domain static hash map, tld list is obtained from of iana.org
Documentation

tld

Crates.io Documentation Rust License

Fast compile-time static perfect hash set of all Top-Level Domains (TLDs), automatically kept in sync with the official IANA Root Zone Database.

Features

  • O(1) lookups with zero runtime allocation powered by phf.
  • 📦 no_std compatible out of the box.
  • 🔄 Automated weekly updates from IANA.
  • 🔤 Case-insensitive & exact lookup helpers.

Installation

Add to your Cargo.toml:

[dependencies]
tld = "2"

Usage

use tld::{exist, exist_case_insensitive, TLD};

// Exact ASCII lowercase lookup
assert!(exist("com"));
assert!(exist("org"));
assert!(exist("io"));
assert!(exist("ai"));
assert!(!exist("invalidtld"));

// Case-insensitive lookup (no heap allocation)
assert!(exist_case_insensitive("COM"));
assert!(exist_case_insensitive("Io"));
assert!(exist_case_insensitive("XN--FIQS8S"));

// Direct access to compile-time phf::Set
assert!(TLD.contains("net"));
println!("Total TLDs: {}", TLD.len());

License

Licensed under BSD 3-Clause.