Commit a72d1fc0 authored by Ralf's avatar Ralf
Browse files

keep track of the door-locked state

parent afb07f0b
......@@ -17,6 +17,7 @@ pub enum EventsResult {
pub struct Environment {
events: Receiver<Event>,
door_locked: bool,
}
impl Environment {
......@@ -31,6 +32,7 @@ impl Environment {
timeout_chan.recv() => return EventsResult::Timeout,
events.recv() -> ev => {
match ev {
None => return EventsResult::ShuttingDown,
Some(ev) => {
self.record_state(&ev);
for handler in handlers.iter_mut() {
......@@ -40,7 +42,6 @@ impl Environment {
}
}
}
None => return EventsResult::ShuttingDown,
}
}
}
......@@ -48,7 +49,13 @@ impl Environment {
unreachable!()
}
fn record_state(&mut self, ev: &Event) {}
fn record_state(&mut self, ev: &Event) {
match ev {
&Event::DoorLocked(b) =>
self.door_locked = b,
_ => {},
}
}
pub fn door_locked(&self) -> bool {
true
......
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