Module uriparse::authority[][src]

Authority Component

See [RFC3986, Section 3.2].

Authority contains no mutable methods. If you want to change a part of the authority, you must use the Authority::into_parts and Authority::from_parts functions.

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.

Some testing reveals that doing incremental parsing and equality of the host string for IP addresses allow for considerably faster checks. For example, a custom IPv4 parser I wrote performed ~2.5 faster than what the std uses. Part of this is that I have to find the end of the host before I can use the std parser. I may in the future allow Authority comparison with custom written IPv4/IPv6 address parsers.

Structs

Authority

The authority component as defined in [RFC3986, Section 3.2].

InvalidRegisteredName

An error representing an invalid registered name.

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).

Username

The username component of the authority as defined in [RFC3986, Section 3.2.1].

Enums

Host

The host component of the authority as defined in [RFC3986, Section 3.2.2].

InvalidAuthority

An error representing an invalid authority.

InvalidHost

An error representing an invalid host.

InvalidPort

An error representing an invalid port.

InvalidUserInfo

An error representing an invalid user information component.