Module authority

Source
Expand description

Authority Component

See [RFC3986, Section 3.2].

§Examples

use std::convert::TryFrom;

use uriparse::Authority;

let authority = Authority::try_from("example.com").unwrap();
let host = authority.into_parts().2;
let authority =
    Authority::from_parts(Some("username"), Some("password"), host, Some(80)).unwrap();
assert_eq!(authority.to_string(), "username:password@example.com:80");

§Equality

While many components in this library support string comparison, Authority does not. This comes down to it just being too expensive to do a proper host comparison. To do so would require conversion to IpAddr, which in the case of Ipv6Addr can be expensive.

Structs§

Authority
The authority component as defined in [RFC3986, Section 3.2].
Password
The password component of the authority as defined in [RFC3986, Section 3.2.1].
RegisteredName
A host that is a registered name (i.e. not an IP literal).
RegisteredNameError
An error representing an invalid registered name.
Username
The username component of the authority as defined in [RFC3986, Section 3.2.1].

Enums§

AuthorityError
An error representing an invalid authority.
Host
The host component of the authority as defined in [RFC3986, Section 3.2.2].
HostError
An error representing an invalid host.
PasswordError
An error representing an invalid password component.
PortError
An error representing an invalid port.
UsernameError
An error representing an invalid username component.

Functions§

parse_port
Parses the port from the given byte string.