Enum distant_net::common::Host

source ·
pub enum Host {
    Ipv4(Ipv4Addr),
    Ipv6(Ipv6Addr),
    Name(String),
}
Expand description

Represents the host of a destination

Variants

Ipv4(Ipv4Addr)

Ipv6(Ipv6Addr)

Name(String)

Represents a hostname that follows the DoD Internet Host Table Specification:

  • Hostname can be a maximum of 253 characters including ‘.’
  • Each label is a-zA-Z0-9 alongside hyphen (‘-’) and a maximum size of 63 characters
  • Labels can be segmented by periods (‘.’)

Implementations

Indicates whether the host destination is globally routable

Returns true if host is an IPv4 address

Returns true if host is an IPv6 address

Returns true if host is a name

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Parses a host from a str

Examples
// IPv4 address
assert_eq!("127.0.0.1".parse(), Ok(Host::Ipv4(Ipv4Addr::new(127, 0, 0, 1))));

// IPv6 address
assert_eq!("::1".parse(), Ok(Host::Ipv6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1))));

// Valid hostname
assert_eq!("localhost".parse(), Ok(Host::Name("localhost".to_string())));

// Invalid hostname
assert!("local_host".parse::<Host>().is_err());
The associated error which can be returned from parsing.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.