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§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Host
impl<'de> Deserialize<'de> for Host
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromStr for Host
impl FromStr for Host
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
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());
Source§type Err = HostParseError
type Err = HostParseError
The associated error which can be returned from parsing.
impl Eq for Host
impl StructuralPartialEq for Host
Auto Trait Implementations§
impl Freeze for Host
impl RefUnwindSafe for Host
impl Send for Host
impl Sync for Host
impl Unpin for Host
impl UnwindSafe for Host
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more