use crate::schema::redfish::secure_boot::SecureBoot as SecureBootSchema;
use crate::Error;
use crate::NvBmc;
use nv_redfish_core::Bmc;
use nv_redfish_core::NavProperty;
use std::convert::identity;
use std::marker::PhantomData;
use std::sync::Arc;
#[doc(inline)]
pub use crate::schema::redfish::secure_boot::SecureBootCurrentBootType;
pub struct SecureBoot<B: Bmc> {
data: Arc<SecureBootSchema>,
_marker: PhantomData<B>,
}
impl<B: Bmc> SecureBoot<B> {
pub(crate) async fn new(
bmc: &NvBmc<B>,
nav: &NavProperty<SecureBootSchema>,
) -> Result<Self, Error<B>> {
nav.get(bmc.as_ref())
.await
.map_err(crate::Error::Bmc)
.map(|data| Self {
data,
_marker: PhantomData,
})
}
#[must_use]
pub fn raw(&self) -> Arc<SecureBootSchema> {
self.data.clone()
}
#[must_use]
pub fn secure_boot_enable(&self) -> Option<bool> {
self.data.secure_boot_enable.and_then(identity)
}
#[must_use]
pub fn secure_boot_current_boot(&self) -> Option<SecureBootCurrentBootType> {
self.data.secure_boot_current_boot.and_then(identity)
}
}