diff rust/src/sensor.rs @ 587:646f03870762 rust

trying rust
author Matt Johnston <matt@ucc.asn.au>
date Wed, 14 Dec 2016 00:15:14 +0800
parents
children 038734052b20
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/src/sensor.rs	Wed Dec 14 00:15:14 2016 +0800
@@ -0,0 +1,24 @@
+use std::any::Any;
+
+use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
+
+pub struct Sensor {
+}
+
+impl Actor for Sensor {
+    fn receive(&self, message: Box<Any>, context: ActorCell) {
+        if let Ok(message) = Box::<Any>::downcast::<String>(message) {
+            println!("Sensor message! {}", message);
+        } else {
+            println!("Sensor message!");
+        }
+    }
+}
+
+impl Sensor {
+
+    pub fn new(_dummy: ()) -> Sensor {
+        Sensor {}
+
+    }
+}