Crate hostaddr

Source
Expand description

hostaddr

Extended types (Domain, Host, HostAddr) for working with net in Rust.

github LoC Build codecov

docs.rs crates.io crates.io license

English | 简体中文

§Installation

[dependencies]
hostaddr = "0.1"

§Example

use hostaddr::HostAddr;

// parse domain to String
let addr: HostAddr<String> = "example.com".parse().unwrap();

// parse domain with port to Arc<str>
let addr: HostAddr<std::sync::Arc<str>> = "example.com:8080".parse().unwrap();

// parse domain to Vec<u8>
let addr: HostAddr<Vec<u8>> = "example.com".parse().unwrap();

// parse a fully qualified domain name with port to Box<str>
let addr: HostAddr<Box<str>> = "example.com.:8080".parse().unwrap();
§License

hostaddr is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2025 Al Liu.

Structs§

Buffer
An immutable buffer which contains a valid domain.
Domain
A DNS domain name, as . dot-separated labels. Non-ASCII labels are encoded in punycode per IDNA if this is the host of a special URL, or percent encoded for non-special URLs.
HostAddr
A host address, which is consit of a Host and an optional port number.
ParseAsciiDomainError
The provided input could not be parsed because it is not an ASCII syntactically-valid DNS Domain.
ParseAsciiHostError
An error which can be returned when parsing an ASCII Host.
ParseDomainError
The provided input could not be parsed because it is not a syntactically-valid DNS Domain.
ParseHostError
An error which can be returned when parsing a Host.
TryUnwrapError
Error returned by the derived TryUnwrap implementation.

Enums§

Host
The host name
ParseAsciiHostAddrError
An error which can be returned when parsing a HostAddr.
ParseHostAddrError
An error which can be returned when parsing a HostAddr.

Functions§

verify_ascii_domain
Verifies that the input is a valid ASCII domain name.
verify_ascii_domain_allow_percent_encoding
Verifies that the input is a valid ASCII domain name. The input can be a percent-encoded domain name.
verify_domainalloc or std
Verifies that the input is a valid domain name.