diff rust/src/main.rs @ 595:e87655ed8429 rust

add config
author Matt Johnston <matt@ucc.asn.au>
date Thu, 05 Jan 2017 23:26:00 +0800
parents aff50ee77252
children ca8102feaca6
line wrap: on
line diff
--- a/rust/src/main.rs	Wed Jan 04 17:18:44 2017 +0800
+++ b/rust/src/main.rs	Thu Jan 05 23:26:00 2017 +0800
@@ -1,10 +1,18 @@
+#![feature(proc_macro)]
+
 extern crate tokio_core;
 extern crate futures;
-extern crate rustc_serialize;
 #[macro_use]
 extern crate log;
 extern crate env_logger;
 
+#[macro_use]
+extern crate serde_derive;
+extern crate serde;
+
+extern crate toml;
+
+
 use std::io;
 
 use tokio_core::reactor::Core;
@@ -12,6 +20,7 @@
 use futures::sync::{mpsc};
 use sensor::Sensor;
 
+mod config;
 mod sensor;
 mod fridge;
 mod types;
@@ -25,6 +34,9 @@
     println!("Wort Templog");
     debug!("debug log level");
 
+    let config = config::Config::new();
+    println!("{}", config.to_toml_string());
+
     let mut core = Core::new().unwrap();
     let handle = core.handle();
 
@@ -46,7 +58,10 @@
         debug!("sensors {:?}", r);
         let t = sensor_s.clone().send(fridge::Message::Sensor{wort: r.wort(), fridge: r.fridge()})
                     .map(|_| ())
-                    .map_err(|_| ());
+                    .map_err(|e| {
+                        warn!("Send error in sensor_s: {}", e.to_string());
+                        ()
+                    });
         handle.spawn(t);
         r
     });