diff rust/src/paramwaiter.rs @ 594:aff50ee77252 rust

rust working better now with streams and sinks.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 04 Jan 2017 17:18:44 +0800
parents bf138339d20a
children 7bda01659426
line wrap: on
line diff
--- a/rust/src/paramwaiter.rs	Tue Dec 27 00:51:28 2016 +0800
+++ b/rust/src/paramwaiter.rs	Wed Jan 04 17:18:44 2017 +0800
@@ -16,7 +16,6 @@
 impl ParamWaiter {
     fn step(&mut self) -> Params {
         let mut p = Params::defaults();
-        let mut rng = rand::thread_rng();
         p.fridge_setpoint = 17.0 + 4.0*rand::random::<f32>();
         p
     }
@@ -25,10 +24,10 @@
         ParamWaiter {}
     }
 
-    pub fn run(handle: &Handle, rate: u64) -> Box<Stream<Item=Params, Error=io::Error>> {
+    pub fn stream(handle: &Handle) -> Box<Stream<Item=Params, Error=io::Error>> {
         let mut s = ParamWaiter::new();
 
-        let dur = Duration::from_millis(rate);
+        let dur = Duration::from_millis(4000);
         Interval::new(dur, handle).unwrap().map(move |()| {
             s.step()
         }).boxed()