From 41fc1a3f6da6cd2f678f843bb7f31bfe574560de Mon Sep 17 00:00:00 2001 From: Luke Else Date: Mon, 20 Feb 2023 21:25:37 +0000 Subject: [PATCH] Added documentation to ip_and_cidr_from_string() --- src/networking/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/networking/mod.rs b/src/networking/mod.rs index 8b500a2..d35a756 100644 --- a/src/networking/mod.rs +++ b/src/networking/mod.rs @@ -15,6 +15,18 @@ impl Network { // fn get_net_id(self) -> u8 {} } +/// Function that takes in a string reference and returns the result of splitting a string into +/// both its Address and CIDR +/// +/// ``` +/// let ip_string = String::from("192.168.0.1/24"); +/// let result = match ip_and_cidr_from_string(&ip_string) { +/// Err(_) => panic!(), +/// Ok(ip_and_cidr) => ip_and_cidr +/// }; +/// +/// >> (IpAddr::V4(192, 168, 0, 1), 24) +/// ``` pub fn ip_and_cidr_from_string(ip_and_cidr: &String) -> Result<(IpAddr, u8), ip::InvalidIPErr>{ let mut cidr: u8 = Default::default(); let mut ip: String = Default::default();