From f2ad0de89b860c4eda43e73466775ad44d55edd7 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Sat, 11 Feb 2023 17:41:33 +0000 Subject: [PATCH] Tried but can't seem to get Console input (Includes newline character) --- src/main.rs | 20 +++++++++++++++++++- src/networking/mod.rs | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7821af6..9e0d695 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,23 @@ +use std::{io, str::FromStr}; + mod networking; +use networking::ip::{IpAddr}; fn main() { - println!("Hello, World!") + println!("Enter the IP and CIDR for your given network"); + + loop { + let mut ip = String::new(); + io::stdin().read_line(&mut ip).unwrap(); + let ip_address = match IpAddr::from_str(x) { + Err(_) => { + println!("fucked it"); + IpAddr::V4(0, 0, 0, 0) + }, + Ok(ip) => ip, + }; + + println!("you entered, {:?}", ip_address); + } + } diff --git a/src/networking/mod.rs b/src/networking/mod.rs index 3a094e3..2d14f20 100644 --- a/src/networking/mod.rs +++ b/src/networking/mod.rs @@ -1,4 +1,4 @@ -mod ip; +pub mod ip; use ip::IpAddr; #[allow(unused)]