diff rust/src/sensor.rs @ 631:c57821a60e51 rust

rust work in progress ?
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Jul 2019 18:28:34 +0800
parents f3e39e2107fd
children bde302def78e
line wrap: on
line diff
--- a/rust/src/sensor.rs	Fri Apr 19 13:58:56 2019 +0800
+++ b/rust/src/sensor.rs	Sat Jul 06 18:28:34 2019 +0800
@@ -1,8 +1,7 @@
-extern crate tokio_core;
-extern crate futures;
-extern crate futures_cpupool;
 extern crate regex;
 
+use actix::prelude::*;
+
 use std::time::Duration;
 use std::io;
 use std::fs::File;
@@ -18,17 +17,17 @@
 use types::*;
 use ::Config;
 
-pub trait Sensor {
-    fn stream(&self, handle: &Handle) -> Box<Stream<Item=Readings, Error=TemplogError>>;
+pub struct OneWireSensor {
+    config: Config,
+    fridge: Recipient<Readings>,
 }
 
-#[derive(Clone)]
-pub struct OneWireSensor {
-    config: Config,
+impl Actor for OneWireSensor {
+    type Context = Context<Self>;
 }
 
 impl OneWireSensor {
-    pub fn new(config: &Config) -> Self {
+    pub fn new(config: &Config, fridge: Recipient<Readings>) -> Self {
         OneWireSensor {
             config: config.clone(),
         }