#![forbid(unsafe_code)]
use mesh::payload::Protobuf;
use std::sync::Arc;
use vm_resource::CanResolveTo;
use vm_resource::ResourceKind;
pub enum PowerRequestHandleKind {}
impl ResourceKind for PowerRequestHandleKind {
const NAME: &'static str = "power_request";
}
impl CanResolveTo<PowerRequestClient> for PowerRequestHandleKind {
type Input<'a> = ();
}
#[derive(Clone)]
pub struct PowerRequestClient(Arc<dyn Fn(PowerRequest) + Send + Sync>);
impl PowerRequestClient {
pub fn power_request(&self, request: PowerRequest) {
(self.0)(request)
}
}
impl<T: 'static + Fn(PowerRequest) + Send + Sync> From<T> for PowerRequestClient {
fn from(value: T) -> Self {
Self(Arc::new(value))
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Protobuf)]
pub enum PowerRequest {
PowerOff,
Reset,
Hibernate,
TripleFault {
vp: u32,
},
}