Draft web platform structure

This commit is contained in:
Héctor Ramón Jiménez 2019-06-25 03:15:34 +02:00
parent eea9530f38
commit c5703eb00a
26 changed files with 1171 additions and 153 deletions

View file

@ -0,0 +1,42 @@
use super::backend;
use crate::event_loop::ControlFlow;
use instant::Instant;
#[derive(Debug, Clone, Copy)]
pub enum State {
Init,
WaitUntil {
timeout: backend::Timeout,
start: Instant,
end: Instant,
},
Wait {
start: Instant,
},
Poll {
timeout: backend::Timeout,
},
Exit,
}
impl State {
pub fn is_exit(&self) -> bool {
match self {
State::Exit => true,
_ => false,
}
}
}
impl From<State> for ControlFlow {
fn from(state: State) -> ControlFlow {
match state {
State::Init => ControlFlow::Poll,
State::WaitUntil { end, .. } => ControlFlow::WaitUntil(end),
State::Wait { .. } => ControlFlow::Wait,
State::Poll { .. } => ControlFlow::Poll,
State::Exit => ControlFlow::Exit,
}
}
}