inet 0.1.1

This library aids in internet processing.
Documentation
/// Represents an IPv4 address.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct IPv4Address {
    pub octets: [u8; 4],
}

impl IPv4Address {

    /// The unspecified address.
    pub const UNSPECIFIED: IPv4Address = IPv4Address::new(0, 0, 0, 0);

    /// The localhost address.
    pub const LOCALHOST: IPv4Address = IPv4Address::new(127, 0, 0, 1);

    /// The broadcast address.
    pub const BROADCAST: IPv4Address = IPv4Address::new(255, 255, 255, 255);
}

impl IPv4Address {

    /// Creates a new IPv4Address from the bytes.
    ///
    /// ```
    /// use inet::ip::IPv4Address;
    ///
    /// assert_eq!(IPv4Address::new(127, 0, 0, 1), IPv4Address::LOCALHOST);
    /// ```
    pub const fn new(a: u8, b: u8, c: u8, d: u8) -> IPv4Address {
        IPv4Address{ octets: [a, b, c, d] }
    }
}

impl IPv4Address {

    /// Checks if the address is the unspecified address.
    ///
    /// ```
    /// use inet::ip::IPv4Address;
    ///
    /// assert!(IPv4Address::UNSPECIFIED.is_unspecified());
    /// assert!(!IPv4Address::LOCALHOST.is_unspecified());
    /// ```
    pub fn is_unspecified(&self) -> bool {
        self == &IPv4Address::UNSPECIFIED
    }

    /// Checks if the address is a loopback address.
    ///
    /// ```
    /// use inet::ip::IPv4Address;
    ///
    /// assert!(!IPv4Address::UNSPECIFIED.is_loopback());
    /// assert!(IPv4Address::LOCALHOST.is_loopback());
    /// ```
    pub fn is_loopback(&self) -> bool {
        self.octets[0] == 127
    }

    /// Checks if the address is the broadcast address.
    ///
    /// ```
    /// use inet::ip::IPv4Address;
    ///
    /// assert!(!IPv4Address::UNSPECIFIED.is_broadcast());
    /// assert!(IPv4Address::BROADCAST.is_broadcast());
    /// ```
    pub fn is_broadcast(&self) -> bool {
        self == &IPv4Address::BROADCAST
    }
}

impl ToString for IPv4Address {

    /// ```
    /// use inet::ip::IPv4Address;
    ///
    /// assert_eq!(IPv4Address::UNSPECIFIED.to_string(), "0.0.0.0");
    /// assert_eq!(IPv4Address::LOCALHOST.to_string(), "127.0.0.1");
    /// assert_eq!(IPv4Address::BROADCAST.to_string(), "255.255.255.255");
    /// ```
    fn to_string(&self) -> String {
        format!("{}.{}.{}.{}", self.octets[0], self.octets[1], self.octets[2], self.octets[3])
    }
}