1use std::ops;
2
3use dope_core::{driver::schedule, io};
4
5use crate::executor;
6
7pub trait Application<'d>: Sized {
11 #[doc(hidden)]
12 fn install<'app>(call: executor::raw::Install<'_, 'app, 'd, Self>)
13 where
14 'd: 'app,
15 {
16 let _ = call;
17 }
18
19 #[doc(hidden)]
20 fn dispatch<'driver, 'turn, 'app>(
21 call: executor::raw::Dispatch<'_, 'driver, 'turn, 'app, 'd, Self>,
22 ) -> ops::ControlFlow<io::Event<'d>>
23 where
24 'd: 'app;
25
26 #[doc(hidden)]
27 fn activate<'driver, 'turn, 'app>(
28 call: executor::raw::Activate<'_, 'driver, 'turn, 'app, 'd, Self>,
29 ) where
30 'd: 'app;
31
32 #[doc(hidden)]
33 fn pre_park<'driver, 'turn, 'app>(
34 call: executor::raw::PrePark<'_, 'driver, 'turn, 'app, 'd, Self>,
35 ) where
36 'd: 'app;
37
38 #[doc(hidden)]
39 fn progress(call: executor::raw::Progress<'_, '_, 'd, Self>) -> schedule::Progress<'d>;
40
41 #[doc(hidden)]
42 fn shutdown_progress(
43 call: executor::raw::Progress<'_, '_, 'd, Self>,
44 ) -> schedule::Progress<'d> {
45 Self::progress(call)
46 }
47
48 #[doc(hidden)]
49 fn shutdown<'driver, 'turn, 'app>(
50 call: executor::raw::Shutdown<'_, 'driver, 'turn, 'app, 'd, Self>,
51 ) -> executor::raw::Pending<'app, 'd, Self>
52 where
53 'd: 'app;
54
55 #[doc(hidden)]
56 fn finish<'finalization, 'app>(call: executor::raw::Finish<'_, 'finalization, 'app, 'd, Self>)
57 where
58 'd: 'app,
59 {
60 let _ = call;
61 }
62}
63
64impl<'d> Application<'d> for () {
65 fn dispatch<'driver, 'turn, 'app>(
66 call: executor::raw::Dispatch<'_, 'driver, 'turn, 'app, 'd, Self>,
67 ) -> ops::ControlFlow<io::Event<'d>>
68 where
69 'd: 'app,
70 {
71 call.consume()
72 }
73
74 fn activate<'driver, 'turn, 'app>(
75 call: executor::raw::Activate<'_, 'driver, 'turn, 'app, 'd, Self>,
76 ) where
77 'd: 'app,
78 {
79 let _ = call;
80 }
81
82 fn pre_park<'driver, 'turn, 'app>(
83 call: executor::raw::PrePark<'_, 'driver, 'turn, 'app, 'd, Self>,
84 ) where
85 'd: 'app,
86 {
87 let _ = call;
88 }
89
90 fn progress(_call: executor::raw::Progress<'_, '_, 'd, Self>) -> schedule::Progress<'d> {
91 schedule::Progress::Quiescent
92 }
93
94 fn shutdown<'driver, 'turn, 'app>(
95 call: executor::raw::Shutdown<'_, 'driver, 'turn, 'app, 'd, Self>,
96 ) -> executor::raw::Pending<'app, 'd, Self>
97 where
98 'd: 'app,
99 {
100 call.complete()
101 }
102}