Commit ef6c146d authored by Ralf's avatar Ralf
Browse files

implement a first run()

parent 60d4e504
use std::fmt;
use actors::{Actor, LockAction};
mod environment;
mod handlers;
mod situations;
use actors::{Actor, LockAction};
use self::environment::Environment;
/// This type gathers all the actors that are available.
pub struct Actors {
green_led: Box<Actor<bool>>,
......@@ -22,5 +23,16 @@ pub struct Actors {
pub trait Situation : fmt::Debug {
/// The core function of a situation: Run it, handle events, return what
/// happens next.
fn run(&mut self, Actors, &mut environment::Environment) -> (Actors, Option<Box<Situation>>);
fn run(&mut self, Actors, &mut Environment) -> (Actors, Option<Box<Situation>>);
/// Run the given Siutation, and continue with the next one, until there is no next Situation left
pub fn run(s: Box<Situation>, mut actors: Actors, env: &mut Environment) -> Actors {
let mut situation = Some(s);
while let Some(mut s) = situation.take() {
let (new_actors, new_situation) =, env);
actors = new_actors;
situation = new_situation;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment