Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
address
This library provides network address types — IP, socket, domain, endpoint, host, & authority — with strict validation, owned & borrowed variants, and standard library conversions.
Usage
= "0.19.0"
Example
use Authority;
// Parsing normalizes mixed-case domain names to lowercase.
let authority: Authority = "Example.com:443".parse.unwrap;
assert_eq!;
assert!;
assert_eq!;
// Hosts may also be IP addresses; socket addresses convert to & from the standard library types.
let authority: Authority = "[::1]:443".parse.unwrap;
let socket: SocketAddr = authority.to_socket.unwrap.to_std;
assert_eq!;
Features
This crate has no dependencies by default.
idna: AddsDomain::from_unicode&to_unicodefor international domain names. Uses theidnacrate.serde: AddsSerialize&Deserializeimplementations via theserdecrate. Human-readable formats use theDisplay&FromStrstrings. Binary formats use compact binary forms for the IP & socket address types. The version-specific types match the wire format of the standard library types;IPAddress&SocketAddressserialize the IP address as a byte string of 4 or 16 bytes instead of the standard library's enum encoding. TheReftypes deserialize by borrowing from the input; domain names must already be lowercase & escaped input is an error, so use the owned types for mixed-case or escaped input.
Address Types
There are 6 core address types:
IPAddress: Either an IPv4 address or an IPv6 address.- Includes the
IPAddressenum along with theIPv4Address&IPv6Addressstruct types.
- Includes the
SocketAddress: An IP address with an associated port.- Includes the
SocketAddress,SocketAddressV4&SocketAddressV6struct types.
- Includes the
Domain: A domain name.- Includes the
Domain&DomainRefstruct types.
- Includes the
Endpoint: A domain with an associated port.- Includes the
Endpoint&EndpointRefstruct types.
- Includes the
Host: Either a domain or an IP address.- Includes the
Host&HostRefenum types.
- Includes the
Authority: A host with an associated port.- Includes the
Authority&AuthorityRefstruct types.
- Includes the
Owned & Reference Types
Address types that are not Copy come in owned & reference pairs (example: Domain & DomainRef). The Ref types
borrow their text, so they parse & convert without allocating; each side converts to the other.
Domain Names
Domain names are restricted to lowercase ASCII letters, digits, and dashes: dot-separated labels of up to 63 bytes
that do not start or end with a dash, with a total name length of up to 253 bytes. Mixed-case input is normalized to
lowercase when parsing owned types. Underscores, empty labels, and the trailing root dot are invalid. Unicode names
can be converted to their ASCII form with the idna feature.
Standard Library Types
The IP & socket address types are separate from their standard library counterparts so the host & authority types can
compose them and the whole family behaves uniformly. They convert to & from the standard library types. IPv6 socket
addresses do not model flow_info or scope_id: converting from the standard library discards them & converting to
it zeroes them.