use uefi_raw::protocol::misc::{
ResetNotificationProtocol, ResetSystemFn, TimestampProperties, TimestampProtocol,
};
use crate::proto::unsafe_protocol;
use crate::{Result, StatusExt};
#[derive(Debug)]
#[repr(transparent)]
#[unsafe_protocol(TimestampProtocol::GUID)]
pub struct Timestamp(TimestampProtocol);
impl Timestamp {
#[must_use]
pub fn get_timestamp(&self) -> u64 {
unsafe { (self.0.get_timestamp)() }
}
pub fn get_properties(&self) -> Result<TimestampProperties> {
let mut properties = TimestampProperties::default();
unsafe { (self.0.get_properties)(&mut properties) }.to_result_with_val(|| properties)
}
}
#[derive(Debug)]
#[repr(transparent)]
#[unsafe_protocol(ResetNotificationProtocol::GUID)]
pub struct ResetNotification(ResetNotificationProtocol);
impl ResetNotification {
pub fn register_reset_notify(&mut self, reset_function: ResetSystemFn) -> Result {
unsafe { (self.0.register_reset_notify)(&mut self.0, reset_function) }.to_result()
}
pub fn unregister_reset_notify(&mut self, reset_function: ResetSystemFn) -> Result {
unsafe { (self.0.unregister_reset_notify)(&mut self.0, reset_function) }.to_result()
}
}