Draft web platform structure
This commit is contained in:
parent
eea9530f38
commit
c5703eb00a
26 changed files with 1171 additions and 153 deletions
42
src/platform_impl/web/event_loop/state.rs
Normal file
42
src/platform_impl/web/event_loop/state.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue