dope_core/executor/session/
manual.rs1use std::{ops, time};
2
3use crate::driver::schedule::clock;
4
5use crate::executor::{self, drive, root, session};
6
7#[repr(transparent)]
9pub struct Manual<'app, 'life: 'app, 'd: 'life, D: executor::raw::Layout<'d>, Report, Q = ()> {
10 pub(super) access: session::access::Access<'app, 'life, 'd, D, Report, Q>,
11}
12
13impl<'app, 'life: 'app, 'd: 'life, D, Q, Report: crate::io::Report>
14 Manual<'app, 'life, 'd, D, Report, Q>
15where
16 D: executor::raw::App<'d>,
17 Q: executor::Startup,
18{
19 pub fn drive<R>(
20 &mut self,
21 now: clock::Deadline<'d>,
22 root: R,
23 ) -> Result<session::Fixed<'d, R::Output>, drive::Error>
24 where
25 R: root::Root<'d>,
26 {
27 use drive::clock::at;
28
29 self.access.core.check_time(now.into_raw())?;
30 self.access.reborrow().drive_fixed(at(now), root)
31 }
32
33 pub fn drive_for<R>(
34 &mut self,
35 now: clock::Deadline<'d>,
36 timeout: time::Duration,
37 root: R,
38 ) -> Result<session::Fixed<'d, R::Output>, drive::Error>
39 where
40 R: root::Root<'d>,
41 {
42 use drive::clock::{Bound, at};
43
44 self.access.core.check_time(now.into_raw())?;
45 let source = Bound::until(at(now), timeout)?;
46 self.access.reborrow().drive_fixed(source, root)
47 }
48}
49
50impl<'app, 'life: 'app, 'd: 'life, D, Q, Report: crate::io::Report> ops::Deref
51 for Manual<'app, 'life, 'd, D, Report, Q>
52where
53 D: executor::raw::Layout<'d>,
54{
55 type Target = session::access::Access<'app, 'life, 'd, D, Report, Q>;
56
57 fn deref(&self) -> &Self::Target {
58 &self.access
59 }
60}
61
62impl<'d, D: executor::raw::Layout<'d>, Q, Report: crate::io::Report> ops::DerefMut
63 for Manual<'_, '_, 'd, D, Report, Q>
64{
65 fn deref_mut(&mut self) -> &mut Self::Target {
66 &mut self.access
67 }
68}