Crate addr[−][src]
Robust domain name parsing using the Public Suffix List
This library allows you to easily and accurately parse any given domain name.
Examples
use addr::{DnsName, DomainName, Error}; // You can find out the root domain // or extension of any given domain name let domain = DomainName::parse("www.example.com")?; assert_eq!(domain.root(), Some("example.com")); assert_eq!(domain.suffix(), "com"); let domain = DomainName::parse("www.食狮.中国")?; assert_eq!(domain.root(), Some("食狮.中国")); assert_eq!(domain.suffix(), "中国"); let domain = DomainName::parse("www.xn--85x722f.xn--55qx5d.cn")?; assert_eq!(domain.root(), Some("xn--85x722f.xn--55qx5d.cn")); assert_eq!(domain.suffix(), "xn--55qx5d.cn"); let domain = DomainName::parse("a.b.example.uk.com")?; assert_eq!(domain.root(), Some("example.uk.com")); assert_eq!(domain.suffix(), "uk.com"); let name = DnsName::parse("_tcp.example.com.")?; assert_eq!(name.suffix(), Some("com.")); // In any case if the domain's suffix is in the list // then this is definately a registrable domain name assert!(domain.has_known_suffix());
Structs
DnsName | Holds information about a particular DNS name |
DomainName | |
EmailAddress |
Enums
Error | |
Host |
Type Definitions
Result |