nv_redfish/computer_system/
secure_boot.rs1use crate::schema::redfish::secure_boot::SecureBoot as SecureBootSchema;
18use crate::Error;
19use crate::NvBmc;
20use nv_redfish_core::Bmc;
21use nv_redfish_core::NavProperty;
22use std::convert::identity;
23use std::marker::PhantomData;
24use std::sync::Arc;
25use tagged_types::TaggedType;
26
27#[doc(inline)]
28pub use crate::schema::redfish::secure_boot::SecureBootCurrentBootType;
29
30pub type SecureBootEnable = TaggedType<bool, SecureBootEnableTag>;
32#[doc(hidden)]
33#[derive(tagged_types::Tag)]
34#[implement(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
35#[transparent(Debug, Display, Serialize, Deserialize)]
36#[capability(inner_access)]
37pub enum SecureBootEnableTag {}
38
39pub struct SecureBoot<B: Bmc> {
43 data: Arc<SecureBootSchema>,
44 _marker: PhantomData<B>,
45}
46
47impl<B: Bmc> SecureBoot<B> {
48 pub(crate) async fn new(
50 bmc: &NvBmc<B>,
51 nav: &NavProperty<SecureBootSchema>,
52 ) -> Result<Self, Error<B>> {
53 nav.get(bmc.as_ref())
54 .await
55 .map_err(crate::Error::Bmc)
56 .map(|data| Self {
57 data,
58 _marker: PhantomData,
59 })
60 }
61
62 #[must_use]
64 pub fn raw(&self) -> Arc<SecureBootSchema> {
65 self.data.clone()
66 }
67
68 #[must_use]
70 pub fn secure_boot_enable(&self) -> Option<SecureBootEnable> {
71 self.data
72 .secure_boot_enable
73 .and_then(identity)
74 .map(SecureBootEnable::new)
75 }
76
77 #[must_use]
79 pub fn secure_boot_current_boot(&self) -> Option<SecureBootCurrentBootType> {
80 self.data.secure_boot_current_boot.and_then(identity)
81 }
82}