inet 0.1.1

This library aids in internet processing.
Documentation
use crate::domain::Domain;
use crate::ip::IPAddress;

/// Represents an IP address or a domain name.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Host {

    /// An IP Address
    Address(IPAddress),

    /// A Domain Name
    Name(Domain),
}

impl ToString for Host {

    /// ```
    /// use inet::domain::Domain;
    /// use std::convert::TryFrom;
    /// use inet::host::Host;
    /// use inet::ip::{IPv4Address, IPAddress};
    ///
    /// let ip: Host = Host::Address(IPAddress::V4(IPv4Address::LOCALHOST));
    /// assert_eq!(ip.to_string(), "127.0.0.1");
    ///
    /// let domain: Host = Host::Name(Domain::try_from("localhost".as_bytes()).ok().unwrap());
    /// assert_eq!(domain.to_string(), "localhost");
    /// ```
    fn to_string(&self) -> String {
        match self {
            Host::Address(ip) => ip.to_string(),
            Host::Name(domain) => domain.to_string(),
        }
    }
}