summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-04-05 02:04:11 -0500
committertom barrett <spalf0@gmail.com>2018-04-05 02:04:11 -0500
commit22ec8b31c66475f29106f2fda46969e427f2e704 (patch)
treef1f439b793ad93d49bee497e1e5675d177e2f65c /src/bin
parentc297e871b7ce8935dd3bb1c65ecae37000d9a331 (diff)
-changed how data is passed (learned you can serialize a vec) -added targeting struct to ship and got timer prototype
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/client.rs13
1 files changed, 6 insertions, 7 deletions
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<Module> = 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::<usize>().unwrap()].to_owned();
- module.push_str("\n");
- stream.write(module.as_bytes()).unwrap();
+ let module = modules[choice.replace("\n", "").parse::<usize>().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),