sp1_core_executor/mode.rs
1/// Execution mode trait for compile-time specialization of page protection behavior.
2pub trait ExecutionMode: Sized + Send + Sync + Clone + Copy + Default + 'static {
3 /// Whether page protection checks are enabled for this execution mode.
4 ///
5 /// When `false`, all page protection code is eliminated at compile time.
6 const PAGE_PROTECTION_ENABLED: bool;
7}
8
9/// Supervisor execution mode - no page protection checks.
10#[derive(Clone, Copy, Debug, Default)]
11pub struct SupervisorMode;
12
13impl ExecutionMode for SupervisorMode {
14 const PAGE_PROTECTION_ENABLED: bool = false;
15}
16
17/// User execution mode - page protection checks enabled.
18#[derive(Clone, Copy, Debug, Default)]
19pub struct UserMode;
20
21impl ExecutionMode for UserMode {
22 const PAGE_PROTECTION_ENABLED: bool = true;
23}