diff rust/src/sensor.rs @ 592:03b48ec0bb03 rust

fridge, types, configwaiter
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Dec 2016 00:14:58 +0800
parents 4a944663fa8d
children aff50ee77252
line wrap: on
line diff
--- a/rust/src/sensor.rs	Fri Dec 23 00:33:19 2016 +0800
+++ b/rust/src/sensor.rs	Sat Dec 24 00:14:58 2016 +0800
@@ -7,12 +7,7 @@
 use tokio_core::reactor::Interval;
 use tokio_core::reactor::Handle;
 use futures::Stream;
-
-#[derive(Debug)]
-pub struct Reading {
-    name: String,
-    value: Option<f32>,
-}
+use types::*;
 
 pub struct Sensor {
     current: f32,
@@ -23,8 +18,8 @@
     fn step(&mut self) -> Vec<Reading> {
         let mut r = Vec::new();
         self.current = self.current + 0.1;
-        r.push(Reading { name: "aaa".to_string() + &self.suf, value: Some(self.current) });
-        r.push(Reading { name: "b".to_string() + &self.suf, value: Some(self.current/3.0) });
+        r.push(Reading::new("aaa".to_string() + &self.suf, self.current));
+        r.push(Reading::new("b".to_string() + &self.suf, self.current/3.0));
         r
     }