comparison 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
comparison
equal deleted inserted replaced
284:8ea6c90774e3 587:646f03870762
1 use std::any::Any;
2
3 use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
4
5 pub struct Sensor {
6 }
7
8 impl Actor for Sensor {
9 fn receive(&self, message: Box<Any>, context: ActorCell) {
10 if let Ok(message) = Box::<Any>::downcast::<String>(message) {
11 println!("Sensor message! {}", message);
12 } else {
13 println!("Sensor message!");
14 }
15 }
16 }
17
18 impl Sensor {
19
20 pub fn new(_dummy: ()) -> Sensor {
21 Sensor {}
22
23 }
24 }