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