pub fn inject_poweroff_handler(handler: fn(ExitCode))Expand description
Injects a handler that can power off the system.
If no handler is injected, poweroff calls crate::arch::power::try_poweroff.
Injection replaces that behavior: poweroff invokes only the injected handler, which may call
the architecture-specific operation as part of its own policy.
use ostd::power::{self, ExitCode};
fn init() {
power::inject_poweroff_handler(poweroff_policy);
}
fn poweroff_policy(code: ExitCode) {
try_platform_poweroff();
ostd::arch::power::try_poweroff(code);
}
fn try_platform_poweroff() {
// Try a platform-specific poweroff mechanism, if available.
}The function may be called only once; subsequent calls take no effect.