Commit 0518a4ac authored by Ralf's avatar Ralf
Browse files

some more comments

parent 0aa78c01
use std::fmt;
use actors::{Actor, LockAction}; use actors::{Actor, LockAction};
#[macro_use] #[macro_use]
...@@ -5,13 +7,20 @@ mod environment; ...@@ -5,13 +7,20 @@ mod environment;
mod handlers; mod handlers;
mod situations; mod situations;
/// This type gathers all the actors that are available.
pub struct Actors { pub struct Actors {
green_led: Box<Actor<bool>>, green_led: Box<Actor<bool>>,
lock: Box<Actor<LockAction>>, lock: Box<Actor<LockAction>>,
buzz: Box<Actor<bool>>, buzz: Box<Actor<bool>>,
} }
pub trait Situation { /// A [Situation] is something that can deal with all events coming in at a
/// particular time. It has access to the actors and can handle events by
/// using the [Environment]. When done, it has to return back all the actors,
/// and it has to explain whta the next [Situation] is. Returning None will lead
/// to the program being terminated.
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::Environment) -> (Actors, Option<Box<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