Expand description
§tld
A compile-time static perfect hash map of all official top-level domains (TLDs), automatically synchronized from the IANA Root Zone Database.
§Features
- Zero Runtime Allocation / O(1) Lookups: Backed by
phf::Set. no_stdCompatible: Can be used in embedded orno_stdcrates.- Case-insensitive helper:
exist_case_insensitivefor convenience.
§Example
use tld::{exist, exist_case_insensitive, TLD};
// Fast exact lookup (requires lowercase ASCII string)
assert!(exist("com"));
assert!(exist("org"));
assert!(exist("io"));
assert!(exist("uk"));
assert!(!exist("invalidtld"));
// Case-insensitive lookup helper
assert!(exist_case_insensitive("COM"));
assert!(exist_case_insensitive("Xn--FIQS8S"));
// Direct access to the compile-time phf::Set
assert!(TLD.contains("net"));
assert!(TLD.len() > 1400);Statics§
- TLD
- Top level domain static map, list is obtained from iana.org.
Functions§
- exist
- Checks if the given ASCII lowercase string is a valid Top-Level Domain (TLD) in the official IANA database.
- exist_
case_ insensitive - Checks if the given string is a valid Top-Level Domain (TLD), ignoring ASCII case.