Rust

Crate root

Module
What utopia_domains defines at its root.

Contents

use utopia_domains::Domain;
Rust
pub struct Domain<'l> {
    // private fields
}

A domain name, lower-cased, split against a PublicSuffixList into its suffix, registrable name and subdomain.

The suffix search runs once, on the first getter that needs it; the suffix, name and subdomain are then slices of the domain.

Rust
use utopia_domains::Domain;

let domain = Domain::new("Blog.Example.CO.UK")?;
assert_eq!(domain.get(), "blog.example.co.uk");
assert_eq!(domain.suffix(), "co.uk");
assert_eq!(domain.name(), "example");
assert_eq!(domain.sub(), "blog");
assert_eq!(domain.registerable(), "example.co.uk");
PHP
use Utopia\Domains\Domain;

$domain = new Domain('Blog.Example.CO.UK');
echo $domain->get(), "\n";            // blog.example.co.uk
echo $domain->getSuffix(), "\n";      // co.uk
echo $domain->getName(), "\n";        // example
echo $domain->getSub(), "\n";         // blog
echo $domain->getRegisterable(), "\n"; // example.co.uk
use utopia_domains::PublicSuffixList;
Rust
pub struct PublicSuffixList {
    // private fields
}

The Public Suffix List: every rule as written (com, *.ck, !www.ck) with its section, plus the exception and wildcard rules indexed without their ! and *. prefixes.

use utopia_domains::Error;
Rust
pub enum Error {
    Exception {
        message: String,
        code: i64,
    },
    Data(String),
}

Why an operation failed.

PHP: one variant per exception class the library raises.

use utopia_domains::Section;
Rust
pub enum Section {
    Icann,
    Private,
    Other,
}

The section of the Public Suffix List a rule comes from.