use std::sync::Arc;
use crate::core::client::{VimClient, Result};
#[derive(Clone)]
pub struct ManagedObjectView {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl ManagedObjectView {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
pub async fn destroy_view(&self) -> Result<()> {
self.client.invoke_void("", "ManagedObjectView", &self.mo_id, "DestroyView", None).await
}
pub async fn view(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ManagedObjectView", &self.mo_id, "view").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
}