Enum uriparse::authority::Host[][src]

pub enum Host<'host> {
    IPv4Address(Ipv4Addr),
    IPv6Address(Ipv6Addr),
    RegisteredName(RegisteredName<'host>),
}

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

The RFC mentions support for future IP address literals. Of course, as of this moment there exist none, so hosts of the form "[v*...]" where '*' is a hexadecimal digit and '...' is the actual IP literal are not considered valid.

Also, the host is case-insensitive meaning that "example.com" and "ExAmPlE.CoM" refer to the same host. Furthermore, percent-encoding plays no role in equality checking meaning that "example.com" and "exampl%65.com" also refer to the same host. Both of these attributes are reflected in the equality and hash functions.

However, be aware that just because percent-encoding plays no role in equality checking does not mean that the host is normalized. The original host string (in the case of a registered name) will always be preserved as is with no normalization performed.

Variants

An IPv4 address. Based on the std's implementation, leading zeros for octets are allowed for up to three digits. So for example, "000.000.000.000" is still considered a valid IPv4 address, but "000.000.000.0000" is not. Thus, it would be considered a registered name.

An IPv6 address. This will always be encased in brackets ('[' and ']').

Any other host that does not follow the syntax of an IP address. This includes even hosts of the form "999.999.999.999". One might expect this to produce an invalid IPv4 error, but the RFC states that it is a "first-match-wins" algorithm, and that host does not match the IPv4 literal syntax.

This may be changed in the future, since arguments can be made from either side.

Methods

impl<'host> Host<'host>
[src]

Returns whether or not the host is an IPv4 address.

Examples

use std::convert::TryFrom;

use uriparse::Host;

let host = Host::try_from("192.168.1.1").unwrap();
assert!(host.is_ipv4_address());

Returns whether or not the host is an IPv6 address.

Examples

use std::convert::TryFrom;

use uriparse::Host;

let host = Host::try_from("[::1]").unwrap();
assert!(host.is_ipv6_address());

Returns whether or not the host is a registered name.

Examples

use std::convert::TryFrom;

use uriparse::Host;

let host = Host::try_from("example.com").unwrap();
assert!(host.is_registered_name());

Trait Implementations

impl<'host> Clone for Host<'host>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'host> Debug for Host<'host>
[src]

Formats the value using the given formatter. Read more

impl<'host> Eq for Host<'host>
[src]

impl<'host> Hash for Host<'host>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<'host> PartialEq for Host<'host>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'host> Display for Host<'host>
[src]

Formats the value using the given formatter. Read more

impl<'host> From<Host<'host>> for String
[src]

Performs the conversion.

impl From<IpAddr> for Host<'static>
[src]

Performs the conversion.

impl From<Ipv4Addr> for Host<'static>
[src]

Performs the conversion.

impl From<Ipv6Addr> for Host<'static>
[src]

Performs the conversion.

impl<'host> TryFrom<&'host [u8]> for Host<'host>
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<'host> TryFrom<&'host str> for Host<'host>
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

Auto Trait Implementations

impl<'host> Send for Host<'host>

impl<'host> Sync for Host<'host>