From 22ec8b31c66475f29106f2fda46969e427f2e704 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 5 Apr 2018 02:04:11 -0500 Subject: -changed how data is passed (learned you can serialize a vec) -added targeting struct to ship and got timer prototype --- src/bin/client.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/bin') diff --git a/src/bin/client.rs b/src/bin/client.rs index cf12e53..bb99485 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -30,21 +30,20 @@ fn main() { let mut data = String::new(); buff_r.read_line(&mut data).unwrap(); - let mut modules : Vec<&str> = data.split(";").collect(); - modules.pop(); + let modules : Vec = serde_json::from_str(&data.replace("\n","")).unwrap(); println!("Choose your module:"); for (i, module) in modules.iter().enumerate() { - println!("{}) {}", i, module.replace("\n", "")); + println!("{}) {:?}", i, module); } let mut choice = String::new(); io::stdin().read_line(&mut choice).expect("Failed"); - let mut module = modules[choice.replace("\n","").parse::().unwrap()].to_owned(); - module.push_str("\n"); - stream.write(module.as_bytes()).unwrap(); + let module = modules[choice.replace("\n", "").parse::().unwrap()].clone(); + + let send = serde_json::to_string(&module).unwrap() + "\n"; + stream.write(send.as_bytes()).unwrap(); - let module : Module = serde_json::from_str(&module.replace("\n","")).unwrap(); match module { Module::Dashboard => client_dashboard(buff_r), Module::Engines => client_engines(stream, buff_r), -- cgit v1.2.3