summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-04-20 09:15:29 -0500
committertom barrett <spalf0@gmail.com>2018-04-20 09:15:29 -0500
commit7211ed31e5412eb84f8fbf0e3a465305068f1d7c (patch)
tree43c9f407ff3ba4ffdb846315c42b42e66b6fc0de /src/bin
parenta6f21e236f86bc9a9bdcf687ba1086c464d079bc (diff)
-made modules their own structs instead of structs with enumeration
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/client.rs17
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),
}
}