diff --git a/src/networking/ip.rs b/src/networking/ip.rs index c88708e..e252a68 100644 --- a/src/networking/ip.rs +++ b/src/networking/ip.rs @@ -32,6 +32,16 @@ impl ToString for IpAddr { impl FromStr for IpAddr { type Err = InvalidIPErr; /// Function that generates a IpAddr / Err from a string + /// + /// # Limitation + /// Currently only works for IPs of type IPv4 + /// # Example + /// ``` + /// let ip: &str = "127.0.0.1"; + /// + /// let parsed_ip: IpAddr = IpAddr::from_str(ip); + /// ///parsed_ip = IpAddr::V4(127,0,0,1) + /// ``` fn from_str(s: &str) -> Result { let split_ip = s.split('.'); if split_ip.clone().count() != 4 { @@ -86,6 +96,8 @@ mod tests { #[test] #[should_panic] + ///Tests if an invalid Ip will cause a panic when + /// converting from a string to an IpAddr fn invalid_string_to_ip() { use super::*; let ip = "Hello, world";