pathlink
A URL type whose path can also be used as a filesystem path, for Rust.
pathlink supports absolute HTTP and HTTPS links with IPv4, bracketed IPv6,
and domain-name hosts, plus absolute path-only links:
use ;
let http: Link = "http://127.0.0.1:8702/api".parse.expect;
let https: Link = "https://example.com/api".parse.expect;
let idn: Link = "https://bücher.example/api".parse.expect;
let local: Link = "/api".parse.expect;
assert_eq!;
let domain = new.expect;
assert_eq!;
Host parsing intentionally accepts only the URL components represented by
Host: a scheme, host address, and optional port. Userinfo, paths, queries,
and fragments are rejected when parsing a Host.
For HTTP and HTTPS links, an empty path is equivalent to the root path according
to IETF RFC 9110 Section 4.2.3, so parsing https://example.com canonicalizes and
displays it as https://example.com/.
Domain names are normalized to ASCII/Punycode through the url crate's IDNA
handling and then validated as DNS-style labels. Display, equality, ordering,
hashing, and serialization use that normalized form. Address::Domain stores a
validated Domain value backed by immutable shared string storage, so domain
addresses cannot be constructed from an arbitrary String and cloning them does
not clone the underlying domain string.