view 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 source

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 {}

    }
}