Skip to main content

plex_boot/core/
app.rs

1use crate::AppError;
2use crate::core::bootables::DisplayOptions;
3use crate::core::display::GopDisplay;
4use crate::path::DiskManager;
5use uefi::proto::console::text::Input;
6
7/// Outcome for a blocking app run.
8#[must_use]
9pub enum AppResult {
10    /// App finished and returned control to the caller.
11    Done,
12    /// App initiated a boot flow and should not return to the caller.
13    Booted,
14    /// Yield control back to the runner, indicates an App has not finished execution.
15    /// This may be used to trigger a redraw from the runner.
16    Yield,
17    /// App encountered an unrecoverable error during execution.
18    Error(AppError),
19}
20
21/// Borrowed UI and system resources for a running app.
22pub struct AppCtx<'a> {
23    /// Display buffer for drawing. Caller retains ownership.
24    pub display: &'a mut GopDisplay<'a>,
25    /// Input source for key events. Caller retains ownership.
26    pub input: &'a mut Input,
27    /// Disk access helpers scoped to the caller's lifetime.
28    pub disk_manager: &'a DiskManager,
29    /// Image handle for UEFI service calls.
30    pub handle: uefi::Handle,
31}
32
33/// Blocking app entry point.
34pub trait App {
35    /// Executes the application logic, taking in system context resources.
36    fn run(&mut self, ctx: &mut AppCtx) -> AppResult;
37}
38
39/// A trait that defines an App that can be drawn as an entry
40/// in the boot menu.
41pub trait DisplayEntry {
42    /// Returns the options used to display this entry on the screen.
43    fn display_options(&self) -> DisplayOptions;
44}