diff options
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/client.rs | 17 |
1 files changed, 8 insertions, 9 deletions
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<String, Module> = serde_json::from_str(&recv.replace("\n","")).unwrap(); + let modules : Vec<ModuleType> = 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::<usize>().unwrap()).unwrap(); + let module_type = modules.into_iter().nth(choice.replace("\n", "").parse::<usize>().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), } } |