1use std::sync::Arc;
2use crate::core::client::{VimClient, Result};
3#[derive(Clone)]
6pub struct HostVFlashManager {
7 client: Arc<dyn VimClient>,
8 mo_id: String,
9}
10impl HostVFlashManager {
11 pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
12 Self {
13 client,
14 mo_id: mo_id.to_string(),
15 }
16 }
17 pub async fn host_config_v_flash_cache(&self, spec: &crate::types::structs::HostVFlashManagerVFlashCacheConfigSpec) -> Result<()> {
34 let input = HostConfigVFlashCacheRequestType {spec, };
35 self.client.invoke_void("", "HostVFlashManager", &self.mo_id, "HostConfigVFlashCache", Some(&input)).await
36 }
37 pub async fn host_configure_v_flash_resource(&self, spec: &crate::types::structs::HostVFlashManagerVFlashResourceConfigSpec) -> Result<()> {
52 let input = HostConfigureVFlashResourceRequestType {spec, };
53 self.client.invoke_void("", "HostVFlashManager", &self.mo_id, "HostConfigureVFlashResource", Some(&input)).await
54 }
55 pub async fn configure_v_flash_resource_ex_task(&self, device_path: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
90 let input = ConfigureVFlashResourceExRequestType {device_path, };
91 let bytes = self.client.invoke("", "HostVFlashManager", &self.mo_id, "ConfigureVFlashResourceEx_Task", Some(&input)).await?;
92 let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
93 Ok(result)
94 }
95 pub async fn host_get_v_flash_module_default_config(&self, v_flash_module: &str) -> Result<crate::types::structs::VirtualDiskVFlashCacheConfigInfo> {
116 let input = HostGetVFlashModuleDefaultConfigRequestType {v_flash_module, };
117 let bytes = self.client.invoke("", "HostVFlashManager", &self.mo_id, "HostGetVFlashModuleDefaultConfig", Some(&input)).await?;
118 let result: crate::types::structs::VirtualDiskVFlashCacheConfigInfo = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
119 Ok(result)
120 }
121 pub async fn host_remove_v_flash_resource(&self) -> Result<()> {
135 self.client.invoke_void("", "HostVFlashManager", &self.mo_id, "HostRemoveVFlashResource", None).await
136 }
137 pub async fn v_flash_config_info(&self) -> Result<Option<crate::types::structs::HostVFlashManagerVFlashConfigInfo>> {
139 let pv_opt = self.client.fetch_property_raw("", "HostVFlashManager", &self.mo_id, "vFlashConfigInfo").await?;
140 match pv_opt {
141 Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
142 None => Ok(None),
143 }
144 }
145}
146struct HostConfigVFlashCacheRequestType<'a> {
147 spec: &'a crate::types::structs::HostVFlashManagerVFlashCacheConfigSpec,
148}
149
150impl<'a> miniserde::Serialize for HostConfigVFlashCacheRequestType<'a> {
151 fn begin(&self) -> miniserde::ser::Fragment<'_> {
152 miniserde::ser::Fragment::Map(Box::new(HostConfigVFlashCacheRequestTypeSer { data: self, seq: 0 }))
153 }
154}
155
156struct HostConfigVFlashCacheRequestTypeSer<'b, 'a> {
157 data: &'b HostConfigVFlashCacheRequestType<'a>,
158 seq: usize,
159}
160
161impl<'b, 'a> miniserde::ser::Map for HostConfigVFlashCacheRequestTypeSer<'b, 'a> {
162 fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
163 let seq = self.seq;
164 self.seq += 1;
165 match seq {
166 0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HostConfigVFlashCacheRequestType")),
167 1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
168 _ => return None,
169 }
170 }
171}
172struct HostConfigureVFlashResourceRequestType<'a> {
173 spec: &'a crate::types::structs::HostVFlashManagerVFlashResourceConfigSpec,
174}
175
176impl<'a> miniserde::Serialize for HostConfigureVFlashResourceRequestType<'a> {
177 fn begin(&self) -> miniserde::ser::Fragment<'_> {
178 miniserde::ser::Fragment::Map(Box::new(HostConfigureVFlashResourceRequestTypeSer { data: self, seq: 0 }))
179 }
180}
181
182struct HostConfigureVFlashResourceRequestTypeSer<'b, 'a> {
183 data: &'b HostConfigureVFlashResourceRequestType<'a>,
184 seq: usize,
185}
186
187impl<'b, 'a> miniserde::ser::Map for HostConfigureVFlashResourceRequestTypeSer<'b, 'a> {
188 fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
189 let seq = self.seq;
190 self.seq += 1;
191 match seq {
192 0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HostConfigureVFlashResourceRequestType")),
193 1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
194 _ => return None,
195 }
196 }
197}
198struct ConfigureVFlashResourceExRequestType<'a> {
199 device_path: Option<&'a [String]>,
200}
201
202impl<'a> miniserde::Serialize for ConfigureVFlashResourceExRequestType<'a> {
203 fn begin(&self) -> miniserde::ser::Fragment<'_> {
204 miniserde::ser::Fragment::Map(Box::new(ConfigureVFlashResourceExRequestTypeSer { data: self, seq: 0 }))
205 }
206}
207
208struct ConfigureVFlashResourceExRequestTypeSer<'b, 'a> {
209 data: &'b ConfigureVFlashResourceExRequestType<'a>,
210 seq: usize,
211}
212
213impl<'b, 'a> miniserde::ser::Map for ConfigureVFlashResourceExRequestTypeSer<'b, 'a> {
214 fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
215 loop {
216 let seq = self.seq;
217 self.seq += 1;
218 match seq {
219 0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ConfigureVFlashResourceExRequestType")),
220 1 => {
221 let Some(ref val) = self.data.device_path else { continue; };
222 return Some((std::borrow::Cow::Borrowed("devicePath"), val as &dyn miniserde::Serialize));
223 }
224 _ => return None,
225 }
226 }
227 }
228}
229struct HostGetVFlashModuleDefaultConfigRequestType<'a> {
230 v_flash_module: &'a str,
231}
232
233impl<'a> miniserde::Serialize for HostGetVFlashModuleDefaultConfigRequestType<'a> {
234 fn begin(&self) -> miniserde::ser::Fragment<'_> {
235 miniserde::ser::Fragment::Map(Box::new(HostGetVFlashModuleDefaultConfigRequestTypeSer { data: self, seq: 0 }))
236 }
237}
238
239struct HostGetVFlashModuleDefaultConfigRequestTypeSer<'b, 'a> {
240 data: &'b HostGetVFlashModuleDefaultConfigRequestType<'a>,
241 seq: usize,
242}
243
244impl<'b, 'a> miniserde::ser::Map for HostGetVFlashModuleDefaultConfigRequestTypeSer<'b, 'a> {
245 fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
246 let seq = self.seq;
247 self.seq += 1;
248 match seq {
249 0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HostGetVFlashModuleDefaultConfigRequestType")),
250 1 => return Some((std::borrow::Cow::Borrowed("vFlashModule"), &self.data.v_flash_module as &dyn miniserde::Serialize)),
251 _ => return None,
252 }
253 }
254}