use mssf_com::FabricClient::{
IFabricPropertyManagementClient2, IFabricQueryClient10, IFabricServiceManagementClient6,
};
use windows_core::Interface;
use self::{query_client::QueryClient, svc_mgmt_client::ServiceManagementClient};
pub mod query_client;
pub mod svc_mgmt_client;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone)]
pub struct FabricClient {
com_property_client: IFabricPropertyManagementClient2,
com_service_client: IFabricServiceManagementClient6,
com_query_client: IFabricQueryClient10,
}
impl Default for FabricClient {
fn default() -> Self {
Self::new()
}
}
impl FabricClient {
pub fn new() -> Self {
let com = crate::sync::CreateLocalClient::<IFabricPropertyManagementClient2>();
Self::from_com(com)
}
pub fn get_com(&self) -> IFabricPropertyManagementClient2 {
self.com_property_client.clone()
}
pub fn from_com(com: IFabricPropertyManagementClient2) -> Self {
let com_property_client = com.clone();
let com_service_client = com
.clone()
.cast::<IFabricServiceManagementClient6>()
.unwrap();
let com_query_client = com.clone().cast::<IFabricQueryClient10>().unwrap();
Self {
com_property_client,
com_service_client,
com_query_client,
}
}
pub fn get_property_manager(&self) -> PropertyManagementClient {
PropertyManagementClient {
_com: self.com_property_client.clone(),
}
}
pub fn get_query_manager(&self) -> QueryClient {
QueryClient::from_com(self.com_query_client.clone())
}
pub fn get_service_manager(&self) -> ServiceManagementClient {
ServiceManagementClient::from_com(self.com_service_client.clone())
}
}
pub struct PropertyManagementClient {
_com: IFabricPropertyManagementClient2,
}