Skip to main content

cadmus_core/device/power/
manager.rs

1//! Power Manager trait definition.
2
3use crate::device::power::error::PowerError;
4
5/// Trait for device power state management (suspend and resume).
6pub trait PowerManager: Send + Sync {
7    /// Suspends the device to RAM.
8    ///
9    /// This method deactivates the touch screen, flushes dirty pages,
10    /// and triggers low-power mode.
11    ///
12    /// # Errors
13    ///
14    /// Returns [`PowerError`] if any write or sync operation fails.
15    fn suspend(&self) -> Result<(), PowerError>;
16
17    /// Resumes the device from suspend.
18    ///
19    /// This method reactivates the touch screen and applies any necessary
20    /// model-specific wake up commands.
21    ///
22    /// # Errors
23    ///
24    /// Returns [`PowerError`] if any write operation fails.
25    fn resume(&self) -> Result<(), PowerError>;
26
27    /// Initializes and enables all available CPU cores on startup.
28    ///
29    /// # Errors
30    ///
31    /// Returns [`PowerError`] if scanning or enabling fails.
32    fn init_cores(&self) -> Result<(), PowerError> {
33        Ok(())
34    }
35
36    /// Restores CPU cores to their initial state on shutdown.
37    ///
38    /// # Errors
39    ///
40    /// Returns [`PowerError`] if writing the saved states fails.
41    fn restore_cores(&self) -> Result<(), PowerError> {
42        Ok(())
43    }
44}