From 7211ed31e5412eb84f8fbf0e3a465305068f1d7c Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 20 Apr 2018 09:15:29 -0500 Subject: -made modules their own structs instead of structs with enumeration --- src/bin/client.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/bin') diff --git a/src/bin/client.rs b/src/bin/client.rs index 1766a59..a26f68a 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -5,9 +5,8 @@ use std::io; use std::io::BufReader; use std::io::prelude::*; use std::net::TcpStream; -use std::collections::BTreeMap; -use space::module::{Module, ModuleType}; +use space::module::ModuleType; use space::client::mining::client_mining; use space::client::engines::client_engines; use space::client::dashboard::client_dashboard; @@ -32,24 +31,24 @@ fn main() { let mut recv = String::new(); buff_r.read_line(&mut recv).unwrap(); - let modules : BTreeMap = serde_json::from_str(&recv.replace("\n","")).unwrap(); + let modules : Vec = serde_json::from_str(&recv.replace("\n","")).unwrap(); println!("Choose your module:"); - for (i, module) in modules.keys().enumerate() { + for (i, module) in modules.iter().enumerate() { println!("{}) {:?}", i, module); } let mut choice = String::new(); io::stdin().read_line(&mut choice).expect("Failed"); - let module = modules.values().nth(choice.replace("\n", "").parse::().unwrap()).unwrap(); + let module_type = modules.into_iter().nth(choice.replace("\n", "").parse::().unwrap()).unwrap(); - let send = serde_json::to_string(&module).unwrap() + "\n"; + let send = serde_json::to_string(&module_type).unwrap() + "\n"; stream.write(send.as_bytes()).unwrap(); - match module.module_type { + match module_type { ModuleType::Dashboard => client_dashboard(buff_r), ModuleType::Engines => client_engines(stream, buff_r), - ModuleType::Mining{..} => client_mining(stream, buff_r), - ModuleType::Navigation{..} => client_navigation(name, stream, buff_r), + ModuleType::Mining => client_mining(stream, buff_r), + ModuleType::Navigation => client_navigation(name, stream, buff_r), } } -- cgit v1.2.3