From ccac666b3d46021b8f9ddff2a35362673fa9269a Mon Sep 17 00:00:00 2001 From: youyuanwu <48816116+youyuanwu@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:02:50 -0700 Subject: [PATCH] Remove generated client wrapper and generator (#44) Generating a safe wrapping for fabric client is too ambitious. In practice the generated wrapper needs to be hand wrapped anyway in practice as observed in the work of doing FabricClient safe wrapping. The complete safe wrapping in practice is never generated. See: https://github.com/Azure/service-fabric-rs/pull/19 The generator is a pain to maintain as well due to windows-metadata does not have an stable api yet. Every time a windows-rs upgrade, the generator requires a lot of fixes. For all these reasons, there is no advantage maintaining the generated safe wrappings, so I am removing it in this PR. In future all safe wrapping are going to be manually wrapped, as they already are. If the windows-metadata or windows-bindgen crate supports api to access to the unsafe com bindings syntax structures in future, this work can be revived. --- .github/workflows/generate.yaml | 3 - CMakeLists.txt | 5 - Cargo.lock | 36 - crates/libs/core/src/client/gen/app.rs | 452 ------------ crates/libs/core/src/client/gen/health.rs | 341 --------- crates/libs/core/src/client/gen/mgmt.rs | 696 ------------------ crates/libs/core/src/client/gen/mod.rs | 7 - crates/libs/core/src/client/gen/property.rs | 316 -------- crates/libs/core/src/client/gen/query.rs | 519 ------------- crates/libs/core/src/client/gen/svc.rs | 301 -------- crates/libs/core/src/client/gen/svcgp.rs | 129 ---- crates/libs/core/src/client/mod.rs | 13 +- crates/libs/core/src/client/query_client.rs | 7 +- .../libs/core/src/client/svc_mgmt_client.rs | 8 +- crates/libs/core/src/client/tests.rs | 18 - crates/tools/fabric-gen/Cargo.toml | 14 - crates/tools/fabric-gen/src/gen.rs | 621 ---------------- crates/tools/fabric-gen/src/main.rs | 130 ---- 18 files changed, 3 insertions(+), 3613 deletions(-) delete mode 100644 crates/libs/core/src/client/gen/app.rs delete mode 100644 crates/libs/core/src/client/gen/health.rs delete mode 100644 crates/libs/core/src/client/gen/mgmt.rs delete mode 100644 crates/libs/core/src/client/gen/mod.rs delete mode 100644 crates/libs/core/src/client/gen/property.rs delete mode 100644 crates/libs/core/src/client/gen/query.rs delete mode 100644 crates/libs/core/src/client/gen/svc.rs delete mode 100644 crates/libs/core/src/client/gen/svcgp.rs delete mode 100644 crates/tools/fabric-gen/Cargo.toml delete mode 100644 crates/tools/fabric-gen/src/gen.rs delete mode 100644 crates/tools/fabric-gen/src/main.rs diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 35bbcf75..3ccff7a6 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -27,9 +27,6 @@ jobs: run: > cmake . -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -B build - - name: generate rust client wrapper - run: cmake --build build --config ${{ matrix.BUILD_TYPE }} --target generate_client - - name: remove generated com code run: cmake --build build --config ${{ matrix.BUILD_TYPE }} --target force_clean diff --git a/CMakeLists.txt b/CMakeLists.txt index 42b8f2a6..26230178 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,11 +39,6 @@ add_custom_target(generate_rust WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -add_custom_target(generate_client - COMMAND ${cargo_exe} run -p tools_fabric_gen - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) - add_custom_target(build_rust COMMAND ${cargo_exe} build WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Cargo.lock b/Cargo.lock index 700823ed..01feae8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,15 +80,6 @@ dependencies = [ "serde", ] -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -150,15 +141,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "itertools" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.10" @@ -613,18 +595,6 @@ dependencies = [ "windows-metadata", ] -[[package]] -name = "tools_fabric_gen" -version = "0.1.0" -dependencies = [ - "convert_case", - "itertools", - "proc-macro2", - "quote", - "syn", - "windows-metadata", -] - [[package]] name = "tracing" version = "0.1.40" @@ -685,12 +655,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/crates/libs/core/src/client/gen/app.rs b/crates/libs/core/src/client/gen/app.rs deleted file mode 100644 index 20fe92a9..00000000 --- a/crates/libs/core/src/client/gen/app.rs +++ /dev/null @@ -1,452 +0,0 @@ -pub struct IFabricApplicationManagementClient10Wrap { com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationManagementClient10 } -impl Default for IFabricApplicationManagementClient10Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricApplicationManagementClient10Wrap { - pub fn new() -> IFabricApplicationManagementClient10Wrap { - IFabricApplicationManagementClient10Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationManagementClient10 > () , } - } - pub fn from_com( - com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationManagementClient10, - ) -> IFabricApplicationManagementClient10Wrap { - IFabricApplicationManagementClient10Wrap { com } - } - pub fn CreateApplication( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_APPLICATION_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateApplication(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginCreateApplication(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteApplication( - &self, - applicationName: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteApplication(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteApplication(applicationName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteApplication2( - &self, - deleteDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DELETE_APPLICATION_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteApplication2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteApplication2(deleteDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeployServicePackageToNode( - &self, - applicationTypeName: ::windows_core::PCWSTR, - applicationTypeVersion: ::windows_core::PCWSTR, - serviceManifestName: ::windows_core::PCWSTR, - sharingPolicy: &::mssf_com::Microsoft::ServiceFabric::FABRIC_PACKAGE_SHARING_POLICY_LIST, - nodeName: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeployServicePackageToNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginDeployServicePackageToNode( - applicationTypeName, - applicationTypeVersion, - serviceManifestName, - sharingPolicy, - nodeName, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetApplicationManifest( - &self, - applicationTypeName: ::windows_core::PCWSTR, - applicationTypeVersion: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationManifest(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetApplicationManifest( - applicationTypeName, - applicationTypeVersion, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationUpgradeProgress (& self , applicationName : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationUpgradeProgressResult2 >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationUpgradeProgress(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetApplicationUpgradeProgress( - applicationName, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn MoveNextApplicationUpgradeDomain( - &self, - progress : & :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationUpgradeProgressResult2, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndMoveNextApplicationUpgradeDomain(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginMoveNextApplicationUpgradeDomain(progress, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn MoveNextApplicationUpgradeDomain2( - &self, - applicationName: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - nextUpgradeDomain: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndMoveNextApplicationUpgradeDomain2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginMoveNextApplicationUpgradeDomain2( - applicationName, - nextUpgradeDomain, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ProvisionApplicationType( - &self, - applicationBuildPath: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndProvisionApplicationType(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginProvisionApplicationType( - applicationBuildPath, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ProvisionApplicationType2( - &self, - description : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PROVISION_APPLICATION_TYPE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndProvisionApplicationType2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginProvisionApplicationType2(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ProvisionApplicationType3( - &self, - description : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PROVISION_APPLICATION_TYPE_DESCRIPTION_BASE, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndProvisionApplicationType3(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginProvisionApplicationType3(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RestartDeployedCodePackage( - &self, - restartCodePackageDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_RESTART_DEPLOYED_CODE_PACKAGE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRestartDeployedCodePackage(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginRestartDeployedCodePackage( - restartCodePackageDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RollbackApplicationUpgrade( - &self, - applicationName: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRollbackApplicationUpgrade(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginRollbackApplicationUpgrade( - applicationName, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UnprovisionApplicationType( - &self, - applicationTypeName: ::windows_core::PCWSTR, - applicationTypeVersion: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUnprovisionApplicationType(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUnprovisionApplicationType( - applicationTypeName, - applicationTypeVersion, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UnprovisionApplicationType2( - &self, - description : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_UNPROVISION_APPLICATION_TYPE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUnprovisionApplicationType2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginUnprovisionApplicationType2(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpdateApplication( - &self, - applicationUpdateDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_UPDATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpdateApplication(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUpdateApplication( - applicationUpdateDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpdateApplicationUpgrade( - &self, - description : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_UPGRADE_UPDATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpdateApplicationUpgrade(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginUpdateApplicationUpgrade(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpgradeApplication( - &self, - upgradeDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_UPGRADE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpgradeApplication(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginUpgradeApplication(upgradeDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/health.rs b/crates/libs/core/src/client/gen/health.rs deleted file mode 100644 index 1188e8ad..00000000 --- a/crates/libs/core/src/client/gen/health.rs +++ /dev/null @@ -1,341 +0,0 @@ -pub struct IFabricHealthClient4Wrap { - com: ::mssf_com::Microsoft::ServiceFabric::FabricCommon::FabricClient::IFabricHealthClient4, -} -impl Default for IFabricHealthClient4Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricHealthClient4Wrap { - pub fn new() -> IFabricHealthClient4Wrap { - IFabricHealthClient4Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricHealthClient4 > () , } - } - pub fn from_com( - com: ::mssf_com::Microsoft::ServiceFabric::FabricCommon::FabricClient::IFabricHealthClient4, - ) -> IFabricHealthClient4Wrap { - IFabricHealthClient4Wrap { com } - } pub fn GetApplicationHealth (& self , applicationName : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetApplicationHealth( - applicationName, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricApplicationHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetApplicationHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetClusterHealth (& self , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_CLUSTER_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricClusterHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterHealth(healthPolicy, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetClusterHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_CLUSTER_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricClusterHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetClusterHealthChunk (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_CLUSTER_HEALTH_CHUNK_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetClusterHealthChunkResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterHealthChunk(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterHealthChunk(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedApplicationHealth (& self , applicationName : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , nodeName : :: windows_core :: PCWSTR , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricDeployedApplicationHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedApplicationHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedApplicationHealth( - applicationName, - nodeName, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedApplicationHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_APPLICATION_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricDeployedApplicationHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedApplicationHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedApplicationHealth2( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedServicePackageHealth (& self , applicationName : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , serviceManifestName : :: windows_core :: PCWSTR , nodeName : :: windows_core :: PCWSTR , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricDeployedServicePackageHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedServicePackageHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedServicePackageHealth( - applicationName, - serviceManifestName, - nodeName, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedServicePackageHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricDeployedServicePackageHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedServicePackageHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedServicePackageHealth2( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetNodeHealth (& self , nodeName : :: windows_core :: PCWSTR , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_CLUSTER_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricNodeHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetNodeHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetNodeHealth(nodeName, healthPolicy, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetNodeHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_NODE_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricNodeHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetNodeHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetNodeHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetPartitionHealth (& self , partitionId : :: windows_core :: GUID , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPartitionHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetPartitionHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetPartitionHealth( - partitionId, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetPartitionHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PARTITION_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPartitionHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetPartitionHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetPartitionHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetReplicaHealth (& self , partitionId : :: windows_core :: GUID , replicaId : i64 , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricReplicaHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetReplicaHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetReplicaHealth( - partitionId, - replicaId, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetReplicaHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_REPLICA_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricReplicaHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetReplicaHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetReplicaHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceHealth (& self , serviceName : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , healthPolicy : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_HEALTH_POLICY , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceHealth(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetServiceHealth( - serviceName, - healthPolicy, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceHealth2 (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_HEALTH_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceHealthResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceHealth2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceHealth2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/mgmt.rs b/crates/libs/core/src/client/gen/mgmt.rs deleted file mode 100644 index d51e5ca2..00000000 --- a/crates/libs/core/src/client/gen/mgmt.rs +++ /dev/null @@ -1,696 +0,0 @@ -pub struct IFabricClusterManagementClient10Wrap { com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricClusterManagementClient10 } -impl Default for IFabricClusterManagementClient10Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricClusterManagementClient10Wrap { - pub fn new() -> IFabricClusterManagementClient10Wrap { - IFabricClusterManagementClient10Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricClusterManagementClient10 > () , } - } - pub fn from_com( - com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricClusterManagementClient10, - ) -> IFabricClusterManagementClient10Wrap { - IFabricClusterManagementClient10Wrap { com } - } - pub fn ActivateNode( - &self, - nodeName: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndActivateNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginActivateNode(nodeName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeactivateNode( - &self, - nodeName: ::windows_core::PCWSTR, - intent: ::mssf_com::Microsoft::ServiceFabric::FABRIC_NODE_DEACTIVATION_INTENT, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeactivateNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeactivateNode(nodeName, intent, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetClusterConfiguration( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterConfiguration(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterConfiguration(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetClusterConfiguration2( - &self, - apiVersion: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterConfiguration2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterConfiguration2(apiVersion, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetClusterConfigurationUpgradeStatus (& self , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricOrchestrationUpgradeStatusResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterConfigurationUpgradeStatus(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterConfigurationUpgradeStatus(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetClusterManifest( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterManifest(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterManifest(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetClusterManifest2( - &self, - queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_CLUSTER_MANIFEST_QUERY_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterManifest2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterManifest2(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetFabricUpgradeProgress (& self , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricUpgradeProgressResult2 >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetFabricUpgradeProgress(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetFabricUpgradeProgress(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetUpgradeOrchestrationServiceState( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetUpgradeOrchestrationServiceState(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetUpgradeOrchestrationServiceState(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetUpgradesPendingApproval( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetUpgradesPendingApproval(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetUpgradesPendingApproval(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn MoveNextFabricUpgradeDomain( - &self, - progress : & :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricUpgradeProgressResult2, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndMoveNextFabricUpgradeDomain(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginMoveNextFabricUpgradeDomain(progress, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn MoveNextFabricUpgradeDomain2( - &self, - nextUpgradeDomain: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndMoveNextFabricUpgradeDomain2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginMoveNextFabricUpgradeDomain2( - nextUpgradeDomain, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn NodeStateRemoved( - &self, - nodeName: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndNodeStateRemoved(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginNodeStateRemoved(nodeName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ProvisionFabric( - &self, - codeFilepath: ::windows_core::PCWSTR, - clusterManifestFilepath: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndProvisionFabric(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginProvisionFabric( - codeFilepath, - clusterManifestFilepath, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RecoverPartition( - &self, - partitionId: ::windows_core::GUID, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRecoverPartition(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRecoverPartition(partitionId, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RecoverPartitions( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRecoverPartitions(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRecoverPartitions(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RecoverServicePartitions( - &self, - serviceName: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRecoverServicePartitions(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRecoverServicePartitions(serviceName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RecoverSystemPartitions( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRecoverSystemPartitions(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRecoverSystemPartitions(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ResetPartitionLoad( - &self, - partitionId: ::windows_core::GUID, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndResetPartitionLoad(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginResetPartitionLoad(partitionId, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RestartNode( - &self, - restartNodeDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_RESTART_NODE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRestartNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRestartNode(restartNodeDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RollbackFabricUpgrade( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRollbackFabricUpgrade(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRollbackFabricUpgrade(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn SetUpgradeOrchestrationServiceState (& self , state : :: windows_core :: PCWSTR , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricUpgradeOrchestrationServiceStateResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndSetUpgradeOrchestrationServiceState(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginSetUpgradeOrchestrationServiceState(state, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn StartApprovedUpgrades( - &self, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndStartApprovedUpgrades(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginStartApprovedUpgrades(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn StartNode( - &self, - startNodeDescription: &::mssf_com::Microsoft::ServiceFabric::FABRIC_START_NODE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndStartNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginStartNode(startNodeDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn StopNode( - &self, - stopNodeDescription: &::mssf_com::Microsoft::ServiceFabric::FABRIC_STOP_NODE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndStopNode(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginStopNode(stopNodeDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn ToggleVerboseServicePlacementHealthReporting( - &self, - enabled: windows::Win32::Foundation::BOOLEAN, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { - self.com - .EndToggleVerboseServicePlacementHealthReporting(ctx) - }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginToggleVerboseServicePlacementHealthReporting( - enabled, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UnprovisionFabric( - &self, - codeVersion: ::windows_core::PCWSTR, - configVersion: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUnprovisionFabric(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUnprovisionFabric( - codeVersion, - configVersion, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpdateFabricUpgrade( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_UPGRADE_UPDATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpdateFabricUpgrade(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginUpdateFabricUpgrade(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpgradeConfiguration( - &self, - startUpgradeDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_START_UPGRADE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpgradeConfiguration(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUpgradeConfiguration( - startUpgradeDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpgradeFabric( - &self, - upgradeDescription: &::mssf_com::Microsoft::ServiceFabric::FABRIC_UPGRADE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpgradeFabric(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginUpgradeFabric(upgradeDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/mod.rs b/crates/libs/core/src/client/gen/mod.rs deleted file mode 100644 index 1041e7bc..00000000 --- a/crates/libs/core/src/client/gen/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod app; -pub mod health; -pub mod mgmt; -pub mod property; -pub mod query; -pub mod svc; -pub mod svcgp; diff --git a/crates/libs/core/src/client/gen/property.rs b/crates/libs/core/src/client/gen/property.rs deleted file mode 100644 index 59cac374..00000000 --- a/crates/libs/core/src/client/gen/property.rs +++ /dev/null @@ -1,316 +0,0 @@ -pub struct IFabricPropertyManagementClient2Wrap { com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyManagementClient2 } -impl Default for IFabricPropertyManagementClient2Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricPropertyManagementClient2Wrap { - pub fn new() -> IFabricPropertyManagementClient2Wrap { - IFabricPropertyManagementClient2Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyManagementClient2 > () , } - } - pub fn from_com( - com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyManagementClient2, - ) -> IFabricPropertyManagementClient2Wrap { - IFabricPropertyManagementClient2Wrap { com } - } - pub fn CreateName( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateName(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginCreateName(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteName( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteName(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteName(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteProperty( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyName: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteProperty(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteProperty(name, propertyName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn EnumerateProperties (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , includeValues : windows :: Win32 :: Foundation :: BOOLEAN , previousResult : & :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyEnumerationResult , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyEnumerationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndEnumerateProperties(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginEnumerateProperties( - name, - includeValues, - previousResult, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn EnumerateSubNames (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , previousResult : & :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricNameEnumerationResult , recursive : windows :: Win32 :: Foundation :: BOOLEAN , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricNameEnumerationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndEnumerateSubNames(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginEnumerateSubNames( - name, - previousResult, - recursive, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetProperty (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , propertyName : :: windows_core :: PCWSTR , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyValueResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetProperty(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetProperty(name, propertyName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetPropertyMetadata (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , propertyName : :: windows_core :: PCWSTR , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricPropertyMetadataResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetPropertyMetadata(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetPropertyMetadata(name, propertyName, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn NameExists( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndNameExists(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginNameExists(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn PutCustomPropertyOperation( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyOperation : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PUT_CUSTOM_PROPERTY_OPERATION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndPutCustomPropertyOperation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginPutCustomPropertyOperation( - name, - propertyOperation, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn PutPropertyDouble( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyName: ::windows_core::PCWSTR, - data: f64, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndPutPropertyDouble(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginPutPropertyDouble( - name, - propertyName, - data, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn PutPropertyGuid( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyName: ::windows_core::PCWSTR, - data: &::windows_core::GUID, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndPutPropertyGuid(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginPutPropertyGuid(name, propertyName, data, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn PutPropertyInt64( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyName: ::windows_core::PCWSTR, - data: i64, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndPutPropertyInt64(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginPutPropertyInt64(name, propertyName, data, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn PutPropertyWString( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - propertyName: ::windows_core::PCWSTR, - data: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndPutPropertyWString(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginPutPropertyWString( - name, - propertyName, - data, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/query.rs b/crates/libs/core/src/client/gen/query.rs deleted file mode 100644 index af8bc338..00000000 --- a/crates/libs/core/src/client/gen/query.rs +++ /dev/null @@ -1,519 +0,0 @@ -pub struct IFabricQueryClient10Wrap { - com: ::mssf_com::Microsoft::ServiceFabric::FabricCommon::FabricClient::IFabricQueryClient10, -} -impl Default for IFabricQueryClient10Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricQueryClient10Wrap { - pub fn new() -> IFabricQueryClient10Wrap { - IFabricQueryClient10Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricQueryClient10 > () , } - } - pub fn from_com( - com: ::mssf_com::Microsoft::ServiceFabric::FabricCommon::FabricClient::IFabricQueryClient10, - ) -> IFabricQueryClient10Wrap { - IFabricQueryClient10Wrap { com } - } pub fn GetApplicationList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetApplicationListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetApplicationList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationLoadInformation (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_LOAD_INFORMATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetApplicationLoadInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationLoadInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetApplicationLoadInformation( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationName (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_NAME_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetApplicationNameResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationName(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetApplicationName(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationTypeList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_APPLICATION_TYPE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetApplicationTypeListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationTypeList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetApplicationTypeList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetApplicationTypePagedList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: PAGED_FABRIC_APPLICATION_TYPE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetApplicationTypePagedListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetApplicationTypePagedList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetApplicationTypePagedList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetClusterLoadInformation (& self , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetClusterLoadInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetClusterLoadInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetClusterLoadInformation(timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedApplicationList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_APPLICATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedApplicationListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedApplicationList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedApplicationList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedApplicationPagedList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PAGED_DEPLOYED_APPLICATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedApplicationPagedListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedApplicationPagedList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedApplicationPagedList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedCodePackageList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_CODE_PACKAGE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedCodePackageListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedCodePackageList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedCodePackageList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedReplicaDetail (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_SERVICE_REPLICA_DETAIL_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedServiceReplicaDetailResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedReplicaDetail(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetDeployedReplicaDetail(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedReplicaList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_SERVICE_REPLICA_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedReplicaListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedReplicaList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetDeployedReplicaList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedServicePackageList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_SERVICE_PACKAGE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedServicePackageListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedServicePackageList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedServicePackageList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetDeployedServiceTypeList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_DEPLOYED_SERVICE_TYPE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetDeployedServiceTypeListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetDeployedServiceTypeList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetDeployedServiceTypeList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetNodeList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_NODE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetNodeListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetNodeList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetNodeList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetNodeLoadInformation (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_NODE_LOAD_INFORMATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetNodeLoadInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetNodeLoadInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetNodeLoadInformation(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetPartitionList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_PARTITION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetPartitionListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetPartitionList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetPartitionList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetPartitionLoadInformation (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PARTITION_LOAD_INFORMATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetPartitionLoadInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetPartitionLoadInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetPartitionLoadInformation( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetProvisionedFabricCodeVersionList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PROVISIONED_CODE_VERSION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetProvisionedCodeVersionListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetProvisionedFabricCodeVersionList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetProvisionedFabricCodeVersionList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetProvisionedFabricConfigVersionList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PROVISIONED_CONFIG_VERSION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetProvisionedConfigVersionListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetProvisionedFabricConfigVersionList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetProvisionedFabricConfigVersionList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetReplicaList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_REPLICA_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetReplicaListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetReplicaList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetReplicaList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetReplicaLoadInformation (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_REPLICA_LOAD_INFORMATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetReplicaLoadInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetReplicaLoadInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetReplicaLoadInformation( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceGroupMemberList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_GROUP_MEMBER_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetServiceGroupMemberListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceGroupMemberList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetServiceGroupMemberList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceGroupMemberTypeList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_GROUP_MEMBER_TYPE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetServiceGroupMemberTypeListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceGroupMemberTypeList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetServiceGroupMemberTypeList( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetServiceListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceName (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_NAME_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetServiceNameResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceName(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceName(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceTypeList (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_TYPE_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetServiceTypeListResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceTypeList(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceTypeList(queryDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetUnplacedReplicaInformation (& self , queryDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_UNPLACED_REPLICA_INFORMATION_QUERY_DESCRIPTION , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricGetUnplacedReplicaInformationResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetUnplacedReplicaInformation(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetUnplacedReplicaInformation( - queryDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/svc.rs b/crates/libs/core/src/client/gen/svc.rs deleted file mode 100644 index 495a0503..00000000 --- a/crates/libs/core/src/client/gen/svc.rs +++ /dev/null @@ -1,301 +0,0 @@ -pub struct IFabricServiceManagementClient6Wrap { com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceManagementClient6 } -impl Default for IFabricServiceManagementClient6Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricServiceManagementClient6Wrap { - pub fn new() -> IFabricServiceManagementClient6Wrap { - IFabricServiceManagementClient6Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceManagementClient6 > () , } - } - pub fn from_com( - com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceManagementClient6, - ) -> IFabricServiceManagementClient6Wrap { - IFabricServiceManagementClient6Wrap { com } - } - pub fn CreateService( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_SERVICE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateService(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginCreateService(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn CreateServiceFromTemplate2( - &self, - serviceFromTemplateDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_FROM_TEMPLATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateServiceFromTemplate2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginCreateServiceFromTemplate2( - serviceFromTemplateDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteService( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteService(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteService(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteService2( - &self, - deleteDescription: &::mssf_com::Microsoft::ServiceFabric::FABRIC_DELETE_SERVICE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteService2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteService2(deleteDescription, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceDescription (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceDescriptionResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceDescription(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceDescription(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn GetServiceManifest( - &self, - applicationTypeName: ::windows_core::PCWSTR, - applicationTypeVersion: ::windows_core::PCWSTR, - serviceManifestName: ::windows_core::PCWSTR, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver< - ::windows_core::Result< - ::mssf_com::Microsoft::ServiceFabric::FabricCommon::IFabricStringResult, - >, - > { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceManifest(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginGetServiceManifest( - applicationTypeName, - applicationTypeVersion, - serviceManifestName, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RegisterServiceNotificationFilter( - &self, - description : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_NOTIFICATION_FILTER_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRegisterServiceNotificationFilter(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginRegisterServiceNotificationFilter( - description, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RemoveReplica( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_REMOVE_REPLICA_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRemoveReplica(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRemoveReplica(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn ResolveServicePartition (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , partitionKeyType : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_PARTITION_KEY_TYPE , partitionKey : & :: core :: ffi :: c_void , previousResult : & :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricResolvedServicePartitionResult , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricResolvedServicePartitionResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndResolveServicePartition(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginResolveServicePartition( - name, - partitionKeyType, - partitionKey, - previousResult, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn RestartReplica( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_RESTART_REPLICA_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndRestartReplica(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginRestartReplica(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UnregisterServiceNotificationFilter( - &self, - filterId: i64, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUnregisterServiceNotificationFilter(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUnregisterServiceNotificationFilter( - filterId, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpdateService( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - serviceUpdateDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_UPDATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpdateService(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUpdateService( - name, - serviceUpdateDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/gen/svcgp.rs b/crates/libs/core/src/client/gen/svcgp.rs deleted file mode 100644 index e2fb5d95..00000000 --- a/crates/libs/core/src/client/gen/svcgp.rs +++ /dev/null @@ -1,129 +0,0 @@ -pub struct IFabricServiceGroupManagementClient4Wrap { com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceGroupManagementClient4 } -impl Default for IFabricServiceGroupManagementClient4Wrap { - fn default() -> Self { - Self::new() - } -} -impl IFabricServiceGroupManagementClient4Wrap { - pub fn new() -> IFabricServiceGroupManagementClient4Wrap { - IFabricServiceGroupManagementClient4Wrap { com : crate :: sync :: CreateLocalClient :: < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceGroupManagementClient4 > () , } - } - pub fn from_com( - com : :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceGroupManagementClient4, - ) -> IFabricServiceGroupManagementClient4Wrap { - IFabricServiceGroupManagementClient4Wrap { com } - } - pub fn CreateServiceGroup( - &self, - description: &::mssf_com::Microsoft::ServiceFabric::FABRIC_SERVICE_GROUP_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateServiceGroup(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginCreateServiceGroup(description, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn CreateServiceGroupFromTemplate2( - &self, - serviceGroupFromTemplateDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_GROUP_FROM_TEMPLATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndCreateServiceGroupFromTemplate2(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginCreateServiceGroupFromTemplate2( - serviceGroupFromTemplateDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn DeleteServiceGroup( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndDeleteServiceGroup(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginDeleteServiceGroup(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } pub fn GetServiceGroupDescription (& self , name : :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_URI , timeoutMilliseconds : u32) -> crate :: sync :: FabricReceiver < :: windows_core :: Result < :: mssf_com :: Microsoft :: ServiceFabric :: FabricCommon :: FabricClient :: IFabricServiceGroupDescriptionResult >>{ - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndGetServiceGroupDescription(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com - .BeginGetServiceGroupDescription(name, timeoutMilliseconds, &callback) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - pub fn UpdateServiceGroup( - &self, - name: ::mssf_com::Microsoft::ServiceFabric::FABRIC_URI, - serviceGroupUpdateDescription : & :: mssf_com :: Microsoft :: ServiceFabric :: FABRIC_SERVICE_GROUP_UPDATE_DESCRIPTION, - timeoutMilliseconds: u32, - ) -> crate::sync::FabricReceiver<::windows_core::Result<()>> { - let (tx, rx) = crate::sync::oneshot_channel(); - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.EndUpdateServiceGroup(ctx) }; - tx.send(res); - }); - let ctx = unsafe { - self.com.BeginUpdateServiceGroup( - name, - serviceGroupUpdateDescription, - timeoutMilliseconds, - &callback, - ) - }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } -} diff --git a/crates/libs/core/src/client/mod.rs b/crates/libs/core/src/client/mod.rs index 0ffa3152..ebea1c86 100644 --- a/crates/libs/core/src/client/mod.rs +++ b/crates/libs/core/src/client/mod.rs @@ -8,14 +8,7 @@ use mssf_com::FabricCommon::FabricClient::{ }; use windows_core::Interface; -use self::{ - gen::{property::IFabricPropertyManagementClient2Wrap, query::IFabricQueryClient10Wrap}, - query_client::QueryClient, - svc_mgmt_client::ServiceManagementClient, -}; - -// TODO: make private. Currently exposed for backward compat -pub mod gen; +use self::{query_client::QueryClient, svc_mgmt_client::ServiceManagementClient}; pub mod query_client; pub mod svc_mgmt_client; @@ -66,9 +59,6 @@ impl FabricClient { pub fn get_property_manager(&self) -> PropertyManagementClient { PropertyManagementClient { _com: self.com_property_client.clone(), - _gen_wrap: IFabricPropertyManagementClient2Wrap::from_com( - self.com_property_client.clone(), - ), } } @@ -85,5 +75,4 @@ impl FabricClient { pub struct PropertyManagementClient { _com: IFabricPropertyManagementClient2, - _gen_wrap: IFabricPropertyManagementClient2Wrap, } diff --git a/crates/libs/core/src/client/query_client.rs b/crates/libs/core/src/client/query_client.rs index 951ce7d9..7699b103 100644 --- a/crates/libs/core/src/client/query_client.rs +++ b/crates/libs/core/src/client/query_client.rs @@ -1,7 +1,6 @@ use std::{ffi::c_void, time::Duration}; use crate::{ - client::IFabricQueryClient10Wrap, iter::{FabricIter, FabricListAccessor}, strings::HSTRINGWrap, }; @@ -21,15 +20,11 @@ use windows_core::{HSTRING, PCWSTR}; pub struct QueryClient { com: IFabricQueryClient10, - _gen_wrap: IFabricQueryClient10Wrap, } impl QueryClient { pub fn from_com(com: IFabricQueryClient10) -> Self { - Self { - com: com.clone(), - _gen_wrap: IFabricQueryClient10Wrap::from_com(com), - } + Self { com: com.clone() } } // manually wrapping the com call since this is a irregular api. diff --git a/crates/libs/core/src/client/svc_mgmt_client.rs b/crates/libs/core/src/client/svc_mgmt_client.rs index c3cd2957..58eb9fcd 100644 --- a/crates/libs/core/src/client/svc_mgmt_client.rs +++ b/crates/libs/core/src/client/svc_mgmt_client.rs @@ -21,20 +21,14 @@ use windows_core::{HSTRING, PCWSTR}; use crate::iter::{FabricIter, FabricListAccessor}; -use super::gen::svc::IFabricServiceManagementClient6Wrap; - // Service Management Client pub struct ServiceManagementClient { com: IFabricServiceManagementClient6, - _gen_wrap: IFabricServiceManagementClient6Wrap, } impl ServiceManagementClient { pub fn from_com(com: IFabricServiceManagementClient6) -> Self { - Self { - com: com.clone(), - _gen_wrap: IFabricServiceManagementClient6Wrap::from_com(com), - } + Self { com: com.clone() } } fn resolve_service_partition_internal( diff --git a/crates/libs/core/src/client/tests.rs b/crates/libs/core/src/client/tests.rs index 72545731..b7e7c481 100644 --- a/crates/libs/core/src/client/tests.rs +++ b/crates/libs/core/src/client/tests.rs @@ -16,24 +16,6 @@ use crate::client::{ FabricClient, }; -use super::gen::query::IFabricQueryClient10Wrap; - -#[test] -fn test_cluster_sync() { - let c = IFabricQueryClient10Wrap::new(); - - let queryDescription = FABRIC_NODE_QUERY_DESCRIPTION { - NodeNameFilter: windows_core::PCWSTR(std::ptr::null()), - Reserved: std::ptr::null_mut(), - }; - let future = c.GetNodeList(&queryDescription, 1000); - - let nodes = future.blocking_recv().unwrap(); - let list = unsafe { nodes.get_NodeList() }; - let node_count = unsafe { (*list).Count }; - assert_ne!(node_count, 0); -} - #[tokio::test] async fn test_fabric_client() { let c = FabricClient::new(); diff --git a/crates/tools/fabric-gen/Cargo.toml b/crates/tools/fabric-gen/Cargo.toml deleted file mode 100644 index 256e21c0..00000000 --- a/crates/tools/fabric-gen/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "tools_fabric_gen" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -windows-metadata = "0.56" -proc-macro2 = "1.0" -syn = "2.0" -quote = "1.0" -convert_case = "0.6.0" -itertools = "0.12.0" diff --git a/crates/tools/fabric-gen/src/gen.rs b/crates/tools/fabric-gen/src/gen.rs deleted file mode 100644 index 359ac4e1..00000000 --- a/crates/tools/fabric-gen/src/gen.rs +++ /dev/null @@ -1,621 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See License.txt in the repo root for license information. -// ------------------------------------------------------------ - -use std::collections::HashMap; - -use windows_metadata::{InterfaceImpl, ParamAttributes, Reader, Type, TypeDef, TypeKind, TypeName}; - -#[derive(Default, Clone)] -pub struct InterfaceLayout { - type_entry: TypeEntry, - func_pairs: HashMap, // key is the function name without begin/end -} - -#[derive(Default, Clone)] -struct ParamEntry { - name: String, - type_entry: TypeEntry, - attr: ParamAttributes, -} - -#[derive(Default, Clone, Debug)] -struct TypeEntry { - ns: String, - name: String, - prefix: String, // mut & etc stuff -} - -impl TypeEntry { - fn from_type_reader(t: &Type, r: &Reader, attr: ParamAttributes) -> TypeEntry { - let empty_str = "".to_string(); - let (name, ns, qualifer) = match t { - Type::TypeDef(x, _) => { - let te: TypeEntry = TypeEntry::from_typedef_reader(x, r); - let tk = x.kind(); - // itf param should be ref - let prefix = match tk { - TypeKind::Interface => "&", - _ => "", - }; - (te.name, te.ns, prefix.to_string()) - } - Type::PWSTR => { - // twist the type based on attr - let t = match attr { - ParamAttributes::In => "PCWSTR", - _ => "PWSTR", - }; - (t.to_string(), "::windows_core".to_string(), empty_str) - } - Type::U32 => ("u32".to_string(), "".to_string(), empty_str), - Type::U16 => ("u16".to_string(), "".to_string(), empty_str), - Type::U8 => ("u8".to_string(), "".to_string(), empty_str), - Type::I64 => ("i64".to_string(), "".to_string(), empty_str), - Type::F64 => ("f64".to_string(), "".to_string(), empty_str), - Type::MutPtr(t, _) => { - let q = match attr { - ParamAttributes::In => "&", - _ => "&mut", - }; - let te = TypeEntry::from_type_reader(t, r, attr); - (te.name, te.ns, format!("{}{}", q, te.prefix)) // te prefix is empty always - } - Type::HRESULT => ( - "HRESULT".to_string(), - "::windows_core".to_string(), - empty_str, - ), - Type::GUID => ("GUID".to_string(), "::windows_core".to_string(), empty_str), - Type::TypeRef(x) => { - let te = TypeEntry::from_typeref(x, r); - (te.name, te.ns, te.prefix) - } - Type::Void => ("c_void".to_string(), "::core::ffi".to_string(), empty_str), - _ => { - panic!("{:?} not supported", t) - } - }; - TypeEntry { - ns, - name, - prefix: qualifer, - } - } - - // custom convert for namespace - fn normalize_namespace(ns: &str) -> String { - // replace . with :: for rust - let ns_str = ns.replace('.', "::"); - ns_str.replace("Windows", "windows") // crate name is lowercase - } - - // fabric types - fn from_typedef_reader(t: &TypeDef, _r: &Reader) -> TypeEntry { - let name = t.name(); - let ns = t.namespace(); - let ns_str = TypeEntry::normalize_namespace(ns); - TypeEntry { - ns: format!("::mssf_com::{}", ns_str), - name: name.to_string(), - prefix: "".to_string(), - } - } - - fn from_typeref(t: &TypeName, _r: &Reader) -> TypeEntry { - let name = t.name(); - let ns = t.namespace(); - let ns_str = TypeEntry::normalize_namespace(ns); - TypeEntry { - ns: ns_str, - name: name.to_string(), - prefix: "".to_string(), - } - } -} - -#[derive(Default, Clone)] -pub struct FuncPair { - begin: String, - begin_param: Vec, // name + type - begin_ret: TypeEntry, // type - end: String, - end_param: Vec, - end_ret: TypeEntry, // type -} - -impl InterfaceLayout { - // removes redundant types for code gen - pub fn to_async(&self) -> InterfaceLayout { - // make a copy - let mut itf: InterfaceLayout = self.clone(); - - for pair in itf.func_pairs.values_mut() { - // callback and ctx are removed - pair.begin_param.retain(|x| { - x.type_entry.name != "IFabricAsyncOperationCallback" - && x.type_entry.name != "IFabricAsyncOperationContext" - }); - // ctx is removed - pair.end_param - .retain(|x| x.type_entry.name != "IFabricAsyncOperationContext"); - } - itf - } - - // merge functions from other into self - // this is for merging parent functions - pub fn merge(&mut self, other: &InterfaceLayout) { - self.func_pairs.extend(other.func_pairs.clone()); - } - - // verify all func pair are ok - // some interfaces have none matching begin and end - fn check_integrity(&self) { - for (f_name, pair) in &self.func_pairs { - assert!( - pair.begin.contains(f_name), - "f_name {}, begin {}", - f_name, - pair.begin - ); - assert!( - pair.end.contains(f_name), - "f_name {}, end {}", - f_name, - pair.end - ); - } - } - - // some sf api end has new return type but the begin is the same - // so the func pair will have empty begin function - fn patch_end_func_without_begin(&mut self) { - // let mut missing_funcs = Vec::::new(); - // for (f_name, pair) in &self.func_pairs{ - // if !pair.begin.contains(f_name){ - // // end api has new version - // missing_funcs.push(f_name.clone()); - // } - // } - - // for f in missing_funcs { - // let pair = self.func_pairs.get_mut(&f).unwrap(); - // assert!(pair.end.contains(&f)); - - // // trim the (version) number from f - // // f. - // } - - // for now we remove such api - let mut missing_funcs = Vec::::new(); - for (f_name, pair) in &self.func_pairs { - if !pair.begin.contains(f_name) { - // end api has new version - missing_funcs.push(f_name.clone()); - } - } - for f in missing_funcs { - let ok = self.func_pairs.remove(&f); - assert!(ok.is_some()); - } - } - - // remove functions - pub fn exclude_funcs(&mut self, fs: &Vec<&str>) { - for f in fs { - let ok = self.func_pairs.remove(*f); - assert!(ok.is_some()); - } - } -} - -pub struct Parser<'a> { - r: &'a Reader, -} - -// return is begin and the trimmed val. -fn trim_begin_end_function_name(name: &str) -> Option<(bool, String)> { - let begin_removed = name.strip_prefix("Begin"); - let end_removed = name.strip_prefix("End"); - if let Some(x) = begin_removed { - return Some((true, String::from(x))); - } - if let Some(x) = end_removed { - return Some((false, String::from(x))); - } - None -} - -impl Parser<'_> { - pub fn new(r: &Reader) -> Parser { - Parser { r } - } - - pub fn get_type_def(&self, tn: &TypeName) -> TypeDef { - let mut type_def = self.r.get_type_def(tn.namespace(), tn.name()).peekable(); - assert!(type_def.peek().is_some()); - - // find the type def for this interface. - let mut x_td: Option = None; - - for td in type_def { - if td.name() != tn.name() { - continue; - } - x_td = Some(td); - } - - assert!(x_td.is_some(), "typedef not found"); - x_td.unwrap() - } - - fn get_parent_type(&self, td: &TypeDef) -> Option { - let parents: Vec = td.interface_impls().collect(); - if parents.is_empty() { - return None; - } - // get the first one - let p = parents[0]; - match p.ty(&[]) { - Type::TypeDef(x, _) => Some(x), - _ => None, - } - } - - pub fn get_interface_layout(&self, td: TypeDef) -> InterfaceLayout { - let r = self.r; - - let tk = td.kind(); - assert_eq!(tk, TypeKind::Interface); - - // find all methods - let mut tmds = td.methods().peekable(); - assert!(tmds.peek().is_some()); - - let mut func_pairs = HashMap::::new(); - - for tmd in tmds { - let tmdn = tmd.name(); - let trimmed_name = trim_begin_end_function_name(tmdn); - if trimmed_name.is_none() { - continue; - } - - // find or initialize the func pair entry - let (is_begin, trimmed_name) = trimmed_name.unwrap(); - let fp_opt = func_pairs.get_mut(&trimmed_name); - if fp_opt.is_none() { - // insert the pair - let new_fp = FuncPair::default(); - func_pairs.insert(trimmed_name.clone(), new_fp); - } - let fp_opt = func_pairs.get_mut(&trimmed_name); - - let fp = fp_opt.unwrap(); - // fill the entry - (if is_begin { &mut fp.begin } else { &mut fp.end }).push_str(tmdn); // should be append empty str - - // fill method info - let mut tmdps = tmd.params().peekable(); - assert!(tmdps.peek().is_some()); - for p in tmdps { - let pn = p.name(); - let flag = p.flags(); - - if pn.is_empty() { - // This might be self ptr - continue; - } - let pe = ParamEntry { - name: pn.to_string(), - type_entry: TypeEntry::default(), - attr: flag, - }; - (if is_begin { - &mut fp.begin_param - } else { - &mut fp.end_param - }) - .push(pe); - } - - let sig = tmd.signature(&[]); - for (i, p) in sig.params.iter().enumerate() { - let pev = if is_begin { - &mut fp.begin_param - } else { - &mut fp.end_param - }; - let pe = &mut pev[i]; - let p_type = TypeEntry::from_type_reader(p, r, pe.attr); - pe.type_entry = p_type; - } - - // ret type does not have attr - let ret_type = TypeEntry::from_type_reader(&sig.return_type, r, ParamAttributes(0)); - - if is_begin { - fp.begin_ret = ret_type; - } else { - fp.end_ret = ret_type; - } - } - InterfaceLayout { - type_entry: TypeEntry::from_typedef_reader(&td, r), - func_pairs, - } - } - - // get all functions including parents - pub fn get_interface_layout_recursive(&self, tn: &TypeName) -> InterfaceLayout { - let td = self.get_type_def(tn); - let mut itf = self.get_interface_layout(td); - - let mut ptd_opt = self.get_parent_type(&td); - while ptd_opt.is_some() { - let ptd = ptd_opt.unwrap(); - let pitf = self.get_interface_layout(ptd); - itf.merge(&pitf); - // loop for the next parent - ptd_opt = self.get_parent_type(&ptd); - } - itf.patch_end_func_without_begin(); - itf.check_integrity(); - itf - } -} - -#[cfg(test)] -mod tests { - - //use windows_metadata::{Type, TypeKind, TypeName}; - - use windows_metadata::TypeName; - - use crate::{gen::TypeEntry, get_reader}; - - use super::Parser; - - #[test] - fn reading_test1() { - let r = get_reader(); - let gen = Parser::new(r); - let itf_layout = gen.get_interface_layout(gen.get_type_def(&TypeName::new( - "Microsoft.ServiceFabric.FabricCommon", - "IFabricAsyncOperationCallback", - ))); - - assert_eq!(itf_layout.type_entry.name, "IFabricAsyncOperationCallback"); - assert_eq!( - itf_layout.type_entry.ns, - "::mssf_com::Microsoft::ServiceFabric::FabricCommon" - ); - - let func_pairs = &itf_layout.func_pairs; - assert_eq!(func_pairs.len(), 0); - } - - #[test] - fn reading_test2() { - let r = get_reader(); - let gen = Parser::new(r); - let itf_layout = gen.get_interface_layout(gen.get_type_def(&TypeName::new( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricClusterManagementClient", - ))); - - assert_eq!( - itf_layout.type_entry.ns, - "::mssf_com::Microsoft::ServiceFabric::FabricCommon::FabricClient" - ); - assert_eq!(itf_layout.type_entry.name, "IFabricClusterManagementClient"); - - let func_pairs = &itf_layout.func_pairs; - assert_eq!(func_pairs.len(), 2); - let pair = func_pairs.get("NodeStateRemoved").unwrap(); - assert_eq!(pair.begin, "BeginNodeStateRemoved"); - - let param = &pair.begin_param; - assert_eq!(param.len(), 4); - let param1 = ¶m[0]; - assert_eq!(param1.name, "nodeName"); - assert_eq!(param1.type_entry.name, "PCWSTR"); - assert_eq!(param1.type_entry.ns, "::windows_core"); - - assert_eq!(pair.end_ret.name, "HRESULT"); - assert_eq!(pair.end_ret.ns, "::windows_core"); - - { - // async layout for generation - let itf2 = itf_layout.to_async(); - let func_pairs = &itf2.func_pairs; - let pair = func_pairs.get("NodeStateRemoved").unwrap(); - assert_eq!(pair.begin, "BeginNodeStateRemoved"); - let param = &pair.begin_param; - // callback and ctx are removed. - assert_eq!(param.len(), 4 - 2); - } - } - - #[test] - fn reading_hierachy() { - let r = get_reader(); - let gen = Parser::new(r); - let td = gen.get_type_def(&TypeName::new( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricClusterManagementClient2", - )); - - let ptd = gen.get_parent_type(&td).unwrap(); - let ptde = TypeEntry::from_typedef_reader(&ptd, r); - assert_eq!(ptde.name, "IFabricClusterManagementClient"); - - let pptd = gen.get_parent_type(&ptd); - assert_eq!(pptd, None); - } -} - -pub mod code { - - use itertools::Itertools; - use proc_macro2::TokenStream; - use quote::quote; - - use super::{FuncPair, InterfaceLayout, ParamEntry}; - - pub struct Gen { - itf: InterfaceLayout, - } - - impl Gen { - pub fn new(itf: InterfaceLayout) -> Gen { - Gen { itf } - } - - pub fn gen(&self) -> TokenStream { - self.gen_iterface() - } - - fn gen_iterface(&self) -> TokenStream { - let itf_type = &self.itf.type_entry.name; - let itf_ns = &self.itf.type_entry.ns; - let itf_full_type: syn::Expr = - syn::parse_str(format!("{}::{}", itf_ns, itf_type).as_str()).unwrap(); - let wrap_ident = quote::format_ident!("{}Wrap", itf_type); - - // output method in alphabetic order - let mut method_stream = TokenStream::new(); - for (name, pair) in self.itf.func_pairs.iter().sorted_by_key(|x| x.0) { - method_stream.extend(self.gen_method(name, pair)); - } - - quote! { - pub struct #wrap_ident - { - com: #itf_full_type - } - - impl Default for #wrap_ident { - fn default() -> Self { - Self::new() - } - } - - impl #wrap_ident{ - pub fn new() -> #wrap_ident { - #wrap_ident { - com: crate::sync::CreateLocalClient::<#itf_full_type>(), - } - } - - pub fn from_com(com: #itf_full_type) -> #wrap_ident { - #wrap_ident { - com - } - } - - #method_stream - } - } - } - - fn gen_method(&self, name: &String, pair: &FuncPair) -> TokenStream { - let f_name = quote::format_ident!("{}", name); - let begin_params = self.gen_begin_params(&pair.begin_param); - let begin_params_call_args = self.gen_begin_params_call_arg(&pair.begin_param); - let ret_t = self.gen_return_type(&pair.end_param); - - let begin_f_ident = quote::format_ident!("{}", pair.begin); - let end_f_ident = quote::format_ident!("{}", pair.end); - - quote! { - pub fn #f_name(&self #begin_params) -> #ret_t{ - let (tx, rx) = crate::sync::oneshot_channel(); - - let callback = crate::sync::AwaitableCallback2::i_new(move |ctx| { - let res = unsafe { self.com.#end_f_ident(ctx) }; - tx.send(res); - }); - let ctx = unsafe { self.com.#begin_f_ident(#begin_params_call_args &callback) }; - if ctx.is_err() { - let (tx2, rx2) = crate::sync::oneshot_channel(); - tx2.send(Err(ctx.err().unwrap())); - rx2 - } else { - rx - } - } - } - } - - fn gen_begin_params(&self, params: &Vec) -> TokenStream { - let mut stream = TokenStream::new(); - - for param in params { - let te = ¶m.type_entry; - let t_ns = if te.ns.is_empty() { - te.name.clone() - } else { - format!("{}::{}", te.ns, te.name) - }; - // param name - let p_name = ¶m.name; - let p_name_ident = quote::format_ident!("{}", p_name); - - let prefix = &te.prefix; - - // type with attribute - let t_ns_prefix = format!("{} {}", prefix, t_ns); - let type_exp: syn::Type = syn::parse_str(t_ns_prefix.as_str()) - .unwrap_or_else(|_| panic!("{}", t_ns_prefix)); - - let token = quote! { - ,#p_name_ident : #type_exp - }; - - stream.extend(token); - } - - stream - } - - // arguments to pass to begin call - fn gen_begin_params_call_arg(&self, params: &Vec) -> TokenStream { - let mut stream = TokenStream::new(); - - for param in params { - let p_name = ¶m.name; - let p_name_ident = quote::format_ident!("{}", p_name); - let token = quote! { - #p_name_ident, - }; - stream.extend(token); - } - - stream - } - - fn gen_return_type(&self, params: &[ParamEntry]) -> TokenStream { - if params.is_empty() { - quote! { - crate::sync::FabricReceiver<::windows_core::Result<()>> - } - } else { - let pe = ¶ms[0]; - let te = &pe.type_entry; - let t: syn::Expr = if te.ns.is_empty() { - // this only works in limited cases - syn::parse_str(te.name.as_str()).unwrap() - // panic!("raw type return not supported ") - } else { - syn::parse_str(format!("{}::{}", te.ns, te.name).as_str()).unwrap() - }; - quote! { - crate::sync::FabricReceiver<::windows_core::Result<#t>> - } - } - } - } -} diff --git a/crates/tools/fabric-gen/src/main.rs b/crates/tools/fabric-gen/src/main.rs deleted file mode 100644 index c6e72e44..00000000 --- a/crates/tools/fabric-gen/src/main.rs +++ /dev/null @@ -1,130 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See License.txt in the repo root for license information. -// ------------------------------------------------------------ - -mod gen; - -use std::{ - path::{Path, PathBuf}, - process::Command, - sync::Once, -}; - -use gen::{code::Gen, Parser}; -use std::io::Write; -use windows_metadata::{File, Reader, TypeName}; - -static FILE_PATH: &str = - r#"build/_deps/fabric_metadata-src/.windows/winmd/Microsoft.ServiceFabric.winmd"#; -static INIT: Once = Once::new(); -// static mut SF_FILE: Vec = vec![]; -static mut SF_READER: Option<&Reader> = None; - -// init the global reader -pub fn initialize() { - INIT.call_once(|| { - let d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - println!("test work dir: {}", d.display()); - let root_dir = d.parent().unwrap().parent().unwrap().parent().unwrap(); - println!("root dir: {}", root_dir.display()); - let abs_path_buf = root_dir.join(FILE_PATH); - // initialization code here - let bytes = std::fs::read(abs_path_buf.as_path()).expect("File not found"); - - let file = File::new(bytes).expect("Invalid metadata"); - - let binding = vec![file]; - //let reader = Reader::new(&binding); - // unsafe { SF_FILE = binding }; - unsafe { SF_READER = Some(Reader::new(binding)) }; - }); -} - -// retrieves the global reader -pub fn get_reader() -> &'static Reader { - initialize(); - unsafe { SF_READER.as_ref().unwrap() } -} - -fn gen_class(ns: &'static str, name: &'static str, file_path: &Path, exclude: &Vec<&str>) { - let reader = get_reader(); - let p = Parser::new(reader); - let mut itf = p.get_interface_layout_recursive(&TypeName::new(ns, name)); - itf.exclude_funcs(exclude); - - let gen = Gen::new(itf.to_async()); - let token = gen.gen(); - - let path = file_path; - let mut output = std::fs::File::create(path).expect("Cannot create file"); - write!(output, "{}", token).expect("write failed"); - - Command::new("rustfmt") - .arg(path) - .spawn() - .unwrap() - .wait() - .expect("fmt failed"); -} - -fn main() { - let gen_folder = Path::new("crates/libs/core/src/client/gen"); - - // property client - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricPropertyManagementClient2", - &gen_folder.join("property.rs"), - &vec![ - "PutPropertyBinary", // has array not yet handled - "SubmitPropertyBatch", // multi return - ], - ); - // IFabricServiceManagementClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricServiceManagementClient6", - &gen_folder.join("svc.rs"), - &vec!["CreateServiceFromTemplate"], // array - ); - //IFabricServiceGroupManagementClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricServiceGroupManagementClient4", - &gen_folder.join("svcgp.rs"), - &vec!["CreateServiceGroupFromTemplate"], // array - ); - - //IFabricApplicationManagementClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricApplicationManagementClient10", - &gen_folder.join("app.rs"), - &vec![], // array - ); - - // IFabricClusterManagementClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricClusterManagementClient10", - &gen_folder.join("mgmt.rs"), - &vec![], - ); - - // IFabricHealthClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricHealthClient4", - &gen_folder.join("health.rs"), - &vec![], - ); - - //IFabricQueryClient - gen_class( - "Microsoft.ServiceFabric.FabricCommon.FabricClient", - "IFabricQueryClient10", - &gen_folder.join("query.rs"), - &vec![], - ); -}