diff --git a/Cargo.toml b/Cargo.toml index 9ca6943..0837abf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,4 @@ edition = "2021" egui = "0.22.0" eframe = "0.22.0" tracing-subscriber = "0.3.16" +subnet_calculator = "0.1.0" diff --git a/src/app/mod.rs b/src/app/mod.rs index cdf8c70..bea0424 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -2,14 +2,16 @@ mod ui; /// Stuct to store the state of the running application pub struct App { - name: String + name: String, + ip: String } impl Default for App { /// Creates the default startup state for the app; fn default() -> Self { Self { - name: String::from("Hello, World!") + name: String::from("Hello, World!"), + ip: String::from("127.0.0.1") } } -} \ No newline at end of file +} diff --git a/src/app/ui/mod.rs b/src/app/ui/mod.rs index d9b386d..be65355 100644 --- a/src/app/ui/mod.rs +++ b/src/app/ui/mod.rs @@ -1,6 +1,10 @@ +use std::str::FromStr; + use crate::app::App; use crate::theme::onedark::ONE_DARK; +use subnet_calculator::{Network, ip::IpAddr}; + impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { let background_frame = egui::Frame::default().fill(ONE_DARK.bg); @@ -16,6 +20,9 @@ impl eframe::App for App { .auto_sized() .show(ctx, |ui| { ui.heading(&self.name); + + ui.text_edit_singleline(&mut self.ip); + Network::create_subnet(&IpAddr::from_str(self.ip.as_str()).unwrap(), 24).unwrap(); for _ in 0..10 { ui.add(egui::Button::new(&self.name)); @@ -23,4 +30,4 @@ impl eframe::App for App { } ); } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index a2c1191..69a6666 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,4 +20,4 @@ fn main() -> Result<(), eframe::Error> { options, Box::new(|_cc| Box::new(App::default())), ) -} \ No newline at end of file +}