From 18d00ce9412d8d690efbb22cb421bb6e3e486a86 Mon Sep 17 00:00:00 2001 From: Youyuan Wu Date: Mon, 9 Dec 2024 17:11:46 -0800 Subject: [PATCH 1/3] no linking works on windows --- Cargo.lock | 19 +- crates/libs/com/Cargo.toml | 6 +- crates/libs/com/build.rs | 21 - .../com/src/ServiceFabric/FabricClient.rs | 195 -- .../com/src/ServiceFabric/FabricCommon.rs | 147 -- .../com/src/ServiceFabric/FabricRuntime.rs | 564 ------ .../com/src/ServiceFabric/FabricTransport.rs | 1587 ----------------- crates/libs/com/src/ServiceFabric/mod.rs | 1 - crates/libs/com/src/lib.rs | 4 +- crates/libs/core/Cargo.toml | 2 + crates/libs/core/src/api/mod.rs | 317 ++++ crates/libs/core/src/client/mod.rs | 22 +- crates/libs/core/src/lib.rs | 2 + crates/libs/core/src/runtime/error.rs | 3 +- crates/libs/core/src/runtime/mod.rs | 14 +- crates/libs/core/src/runtime/node_context.rs | 18 +- crates/libs/core/src/runtime/store.rs | 29 +- crates/libs/core/src/sync/cancel.rs | 9 +- crates/libs/core/src/sync/mod.rs | 2 +- crates/samples/client/src/main.rs | 10 +- crates/samples/echomain-stateful/src/main.rs | 30 +- crates/samples/echomain-stateful2/src/test.rs | 2 +- crates/tools/api/src/main.rs | 57 +- 23 files changed, 425 insertions(+), 2636 deletions(-) delete mode 100644 crates/libs/com/build.rs delete mode 100644 crates/libs/com/src/ServiceFabric/FabricTransport.rs create mode 100644 crates/libs/core/src/api/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 7af8e02c..3a18ba6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,6 +168,16 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -221,7 +231,6 @@ dependencies = [ name = "mssf-com" version = "0.0.16" dependencies = [ - "mssf-metadata", "mssf-pal", ] @@ -232,6 +241,8 @@ dependencies = [ "bitflags", "config", "ctrlc", + "lazy_static", + "libloading", "mssf-com", "mssf-pal", "paste", @@ -242,12 +253,6 @@ dependencies = [ "windows", ] -[[package]] -name = "mssf-metadata" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39323a0ee935ad85894e31a9f42f2f41f5db403b7d2312d85e77b5a99eb8552d" - [[package]] name = "mssf-pal" version = "0.0.16" diff --git a/crates/libs/com/Cargo.toml b/crates/libs/com/Cargo.toml index acc076af..10e06bce 100644 --- a/crates/libs/com/Cargo.toml +++ b/crates/libs/com/Cargo.toml @@ -23,10 +23,6 @@ targets = [] path = "../pal" version = "0.0.16" -[target.'cfg(windows)'.dependencies] -# this dep is required on windows to have the support libs. -mssf-metadata = { version = "0.0.1", optional = true } - [features] default = ["bundled_libs"] -bundled_libs = ["dep:mssf-metadata"] \ No newline at end of file +bundled_libs = [] \ No newline at end of file diff --git a/crates/libs/com/build.rs b/crates/libs/com/build.rs deleted file mode 100644 index eceaeb5f..00000000 --- a/crates/libs/com/build.rs +++ /dev/null @@ -1,21 +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::path::Path; - -fn main() { - if cfg!(unix) { - // Add link dir for fabric libs on linux. - let dir = String::from("/opt/microsoft/servicefabric/bin/Fabric/Fabric.Code/"); - println!("cargo:rustc-link-search={}", Path::new(&dir).display()); - - // On linux, for windows-rs to work we need have a pal shared lib. - // No need to have search dir since it is in the target dir - // let outdir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - - // println!("cargo:rustc-link-search={}", outdir.as_path().display()); - // println!("cargo:rustc-link-lib=static=fabric_rust_pal"); - } -} diff --git a/crates/libs/com/src/ServiceFabric/FabricClient.rs b/crates/libs/com/src/ServiceFabric/FabricClient.rs index 819c219e..378de98f 100644 --- a/crates/libs/com/src/ServiceFabric/FabricClient.rs +++ b/crates/libs/com/src/ServiceFabric/FabricClient.rs @@ -7,201 +7,6 @@ dead_code, clippy::all )] -#[inline] -pub unsafe fn FabricCreateClient( - connectionstrings: &[windows_core::PCWSTR], - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateClient( - connectionstringssize: u16, - connectionstrings: *const windows_core::PCWSTR, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateClient( - connectionstrings.len().try_into().unwrap(), - core::mem::transmute(connectionstrings.as_ptr()), - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateClient2( - connectionstrings: &[windows_core::PCWSTR], - __midl__fabricclientmodule0000: P0, - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateClient2( - connectionstringssize: u16, - connectionstrings: *const windows_core::PCWSTR, - __midl__fabricclientmodule0000: *mut core::ffi::c_void, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateClient2( - connectionstrings.len().try_into().unwrap(), - core::mem::transmute(connectionstrings.as_ptr()), - __midl__fabricclientmodule0000.param().abi(), - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateClient3( - connectionstrings: &[windows_core::PCWSTR], - __midl__fabricclientmodule0002: P0, - __midl__fabricclientmodule0003: P1, - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, -{ - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateClient3( - connectionstringssize: u16, - connectionstrings: *const windows_core::PCWSTR, - __midl__fabricclientmodule0002: *mut core::ffi::c_void, - __midl__fabricclientmodule0003: *mut core::ffi::c_void, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateClient3( - connectionstrings.len().try_into().unwrap(), - core::mem::transmute(connectionstrings.as_ptr()), - __midl__fabricclientmodule0002.param().abi(), - __midl__fabricclientmodule0003.param().abi(), - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateLocalClient( - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateLocalClient( - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateLocalClient(iid, &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateLocalClient2( - __midl__fabricclientmodule0001: P0, - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateLocalClient2( - __midl__fabricclientmodule0001: *mut core::ffi::c_void, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateLocalClient2( - __midl__fabricclientmodule0001.param().abi(), - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateLocalClient3( - __midl__fabricclientmodule0004: P0, - __midl__fabricclientmodule0005: P1, - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, -{ - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateLocalClient3( - __midl__fabricclientmodule0004: *mut core::ffi::c_void, - __midl__fabricclientmodule0005: *mut core::ffi::c_void, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateLocalClient3( - __midl__fabricclientmodule0004.param().abi(), - __midl__fabricclientmodule0005.param().abi(), - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateLocalClient4( - __midl__fabricclientmodule0006: P0, - __midl__fabricclientmodule0007: P1, - clientrole: super::FabricTypes::FABRIC_CLIENT_ROLE, - iid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, -{ - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricCreateLocalClient4( - __midl__fabricclientmodule0006: *mut core::ffi::c_void, - __midl__fabricclientmodule0007: *mut core::ffi::c_void, - clientrole: super::FabricTypes::FABRIC_CLIENT_ROLE, - iid: *const windows_core::GUID, - fabricclient: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateLocalClient4( - __midl__fabricclientmodule0006.param().abi(), - __midl__fabricclientmodule0007.param().abi(), - clientrole, - iid, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricGetDefaultRollingUpgradeMonitoringPolicy( -) -> windows_core::Result { - #[link(name = "FabricClient")] - extern "system" { - pub fn FabricGetDefaultRollingUpgradeMonitoringPolicy( - result: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricGetDefaultRollingUpgradeMonitoringPolicy(&mut result__) - .and_then(|| windows_core::Type::from_abi(result__)) -} windows_core::imp::define_interface!( IFabricApplicationHealthResult, IFabricApplicationHealthResult_Vtbl, diff --git a/crates/libs/com/src/ServiceFabric/FabricCommon.rs b/crates/libs/com/src/ServiceFabric/FabricCommon.rs index 8c61ac83..c9bf1385 100644 --- a/crates/libs/com/src/ServiceFabric/FabricCommon.rs +++ b/crates/libs/com/src/ServiceFabric/FabricCommon.rs @@ -7,153 +7,6 @@ dead_code, clippy::all )] -#[inline] -pub unsafe fn FabricDecryptText( - encryptedtext: P0, - certstorelocation: super::FabricTypes::FABRIC_X509_STORE_LOCATION, -) -> windows_core::Result -where - P0: windows_core::Param, -{ - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricDecryptText( - encryptedtext: windows_core::PCWSTR, - certstorelocation: super::FabricTypes::FABRIC_X509_STORE_LOCATION, - decryptedtext: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricDecryptText( - encryptedtext.param().abi(), - certstorelocation, - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricDecryptValue( - encryptedvalue: P0, -) -> windows_core::Result -where - P0: windows_core::Param, -{ - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricDecryptValue( - encryptedvalue: windows_core::PCWSTR, - decryptedvalue: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricDecryptValue(encryptedvalue.param().abi(), &mut result__) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricEncryptText( - text: P0, - certthumbprint: P1, - certstorename: P2, - certstorelocation: super::FabricTypes::FABRIC_X509_STORE_LOCATION, - algorithmoid: P3, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, - P3: windows_core::Param, -{ - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricEncryptText( - text: windows_core::PCWSTR, - certthumbprint: windows_core::PCWSTR, - certstorename: windows_core::PCWSTR, - certstorelocation: super::FabricTypes::FABRIC_X509_STORE_LOCATION, - algorithmoid: windows_core::PCSTR, - encryptedvalue: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEncryptText( - text.param().abi(), - certthumbprint.param().abi(), - certstorename.param().abi(), - certstorelocation, - algorithmoid.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricEncryptText2( - text: P0, - certfilepath: P1, - algorithmoid: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricEncryptText2( - text: windows_core::PCWSTR, - certfilepath: windows_core::PCWSTR, - algorithmoid: windows_core::PCSTR, - encryptedvalue: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEncryptText2( - text.param().abi(), - certfilepath.param().abi(), - algorithmoid.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricEncryptValue( - certthumbprint: P0, - certstorename: P1, - text: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricEncryptValue( - certthumbprint: windows_core::PCWSTR, - certstorename: windows_core::PCWSTR, - text: windows_core::PCWSTR, - encryptedvalue: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEncryptValue( - certthumbprint.param().abi(), - certstorename.param().abi(), - text.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricGetLastErrorMessage() -> windows_core::Result { - #[link(name = "FabricCommon")] - extern "system" { - pub fn FabricGetLastErrorMessage( - message: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricGetLastErrorMessage(&mut result__).and_then(|| windows_core::Type::from_abi(result__)) -} windows_core::imp::define_interface!( IFabricAsyncOperationCallback, IFabricAsyncOperationCallback_Vtbl, diff --git a/crates/libs/com/src/ServiceFabric/FabricRuntime.rs b/crates/libs/com/src/ServiceFabric/FabricRuntime.rs index 4697f447..60064cf4 100644 --- a/crates/libs/com/src/ServiceFabric/FabricRuntime.rs +++ b/crates/libs/com/src/ServiceFabric/FabricRuntime.rs @@ -7,570 +7,6 @@ dead_code, clippy::all )] -#[inline] -pub unsafe fn FabricBeginCreateRuntime( - riid: *const windows_core::GUID, - exithandler: P0, - timeoutmilliseconds: u32, - callback: P1, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricBeginCreateRuntime( - riid: *const windows_core::GUID, - exithandler: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricBeginCreateRuntime( - riid, - exithandler.param().abi(), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricBeginGetActivationContext( - riid: *const windows_core::GUID, - timeoutmilliseconds: u32, - callback: P0, -) -> windows_core::Result -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricBeginGetActivationContext( - riid: *const windows_core::GUID, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricBeginGetActivationContext( - riid, - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricBeginGetCodePackageActivator( - riid: *const windows_core::GUID, - timeoutmilliseconds: u32, - callback: P0, -) -> windows_core::Result -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricBeginGetCodePackageActivator( - riid: *const windows_core::GUID, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricBeginGetCodePackageActivator( - riid, - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricBeginGetNodeContext( - timeoutmilliseconds: u32, - callback: P0, -) -> windows_core::Result -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricBeginGetNodeContext( - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricBeginGetNodeContext(timeoutmilliseconds, callback.param().abi(), &mut result__) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricCreateKeyValueStoreReplica( - riid: *const windows_core::GUID, - storename: P0, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: P1, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateKeyValueStoreReplica( - riid: *const windows_core::GUID, - storename: windows_core::PCWSTR, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: *mut core::ffi::c_void, - keyvaluestore: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateKeyValueStoreReplica( - riid, - storename.param().abi(), - core::mem::transmute(partitionid), - replicaid, - replicatorsettings, - localstorekind, - localstoresettings, - storeeventhandler.param().abi(), - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateKeyValueStoreReplica2( - riid: *const windows_core::GUID, - storename: P0, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: P1, - secondaryeventhandler: P2, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateKeyValueStoreReplica2( - riid: *const windows_core::GUID, - storename: windows_core::PCWSTR, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: *mut core::ffi::c_void, - secondaryeventhandler: *mut core::ffi::c_void, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, - keyvaluestore: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateKeyValueStoreReplica2( - riid, - storename.param().abi(), - core::mem::transmute(partitionid), - replicaid, - replicatorsettings, - localstorekind, - localstoresettings, - storeeventhandler.param().abi(), - secondaryeventhandler.param().abi(), - notificationmode, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateKeyValueStoreReplica3( - riid: *const windows_core::GUID, - storename: P0, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: P1, - secondaryeventhandler: P2, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateKeyValueStoreReplica3( - riid: *const windows_core::GUID, - storename: windows_core::PCWSTR, - partitionid: windows_core::GUID, - replicaid: i64, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: *mut core::ffi::c_void, - secondaryeventhandler: *mut core::ffi::c_void, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, - keyvaluestore: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateKeyValueStoreReplica3( - riid, - storename.param().abi(), - core::mem::transmute(partitionid), - replicaid, - replicatorsettings, - localstorekind, - localstoresettings, - storeeventhandler.param().abi(), - secondaryeventhandler.param().abi(), - notificationmode, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateKeyValueStoreReplica4( - riid: *const windows_core::GUID, - storename: P0, - partitionid: windows_core::GUID, - replicaid: i64, - servicename: P1, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: P2, - secondaryeventhandler: P3, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, - P3: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateKeyValueStoreReplica4( - riid: *const windows_core::GUID, - storename: windows_core::PCWSTR, - partitionid: windows_core::GUID, - replicaid: i64, - servicename: super::FabricTypes::FABRIC_URI, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: *mut core::ffi::c_void, - secondaryeventhandler: *mut core::ffi::c_void, - notificationmode: super::FabricTypes::FABRIC_KEY_VALUE_STORE_NOTIFICATION_MODE, - keyvaluestore: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateKeyValueStoreReplica4( - riid, - storename.param().abi(), - core::mem::transmute(partitionid), - replicaid, - servicename.param().abi(), - replicatorsettings, - localstorekind, - localstoresettings, - storeeventhandler.param().abi(), - secondaryeventhandler.param().abi(), - notificationmode, - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateKeyValueStoreReplica5( - riid: *const windows_core::GUID, - storename: P0, - partitionid: windows_core::GUID, - replicaid: i64, - servicename: P1, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - kvssettings: *const super::FabricTypes::FABRIC_KEY_VALUE_STORE_REPLICA_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: P2, - secondaryeventhandler: P3, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, - P3: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateKeyValueStoreReplica5( - riid: *const windows_core::GUID, - storename: windows_core::PCWSTR, - partitionid: windows_core::GUID, - replicaid: i64, - servicename: super::FabricTypes::FABRIC_URI, - replicatorsettings: *const super::FabricTypes::FABRIC_REPLICATOR_SETTINGS, - kvssettings: *const super::FabricTypes::FABRIC_KEY_VALUE_STORE_REPLICA_SETTINGS, - localstorekind: super::FabricTypes::FABRIC_LOCAL_STORE_KIND, - localstoresettings: *const core::ffi::c_void, - storeeventhandler: *mut core::ffi::c_void, - secondaryeventhandler: *mut core::ffi::c_void, - keyvaluestore: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateKeyValueStoreReplica5( - riid, - storename.param().abi(), - core::mem::transmute(partitionid), - replicaid, - servicename.param().abi(), - replicatorsettings, - kvssettings, - localstorekind, - localstoresettings, - storeeventhandler.param().abi(), - secondaryeventhandler.param().abi(), - &mut result__, - ) - .map(|| result__) -} -#[inline] -pub unsafe fn FabricCreateRuntime( - riid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricCreateRuntime( - riid: *const windows_core::GUID, - fabricruntime: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricCreateRuntime(riid, &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricEndCreateRuntime( - context: P0, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricEndCreateRuntime( - context: *mut core::ffi::c_void, - fabricruntime: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEndCreateRuntime(context.param().abi(), &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricEndGetActivationContext( - context: P0, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricEndGetActivationContext( - context: *mut core::ffi::c_void, - activationcontext: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEndGetActivationContext(context.param().abi(), &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricEndGetCodePackageActivator( - context: P0, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricEndGetCodePackageActivator( - context: *mut core::ffi::c_void, - activator: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEndGetCodePackageActivator(context.param().abi(), &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricEndGetNodeContext( - context: P0, -) -> windows_core::Result<*mut core::ffi::c_void> -where - P0: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricEndGetNodeContext( - context: *mut core::ffi::c_void, - nodecontext: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricEndGetNodeContext(context.param().abi(), &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricGetActivationContext( - riid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricGetActivationContext( - riid: *const windows_core::GUID, - activationcontext: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricGetActivationContext(riid, &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricGetCodePackageActivator( - riid: *const windows_core::GUID, -) -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricGetCodePackageActivator( - riid: *const windows_core::GUID, - activator: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricGetCodePackageActivator(riid, &mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricGetNodeContext() -> windows_core::Result<*mut core::ffi::c_void> { - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricGetNodeContext( - nodecontext: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricGetNodeContext(&mut result__).map(|| result__) -} -#[inline] -pub unsafe fn FabricLoadEseLocalStoreSettings( - codepackageactivationcontext: P0, - configurationpackagename: P1, - sectionname: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricLoadEseLocalStoreSettings( - codepackageactivationcontext: *mut core::ffi::c_void, - configurationpackagename: windows_core::PCWSTR, - sectionname: windows_core::PCWSTR, - settings: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricLoadEseLocalStoreSettings( - codepackageactivationcontext.param().abi(), - configurationpackagename.param().abi(), - sectionname.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricLoadReplicatorSettings( - codepackageactivationcontext: P0, - configurationpackagename: P1, - sectionname: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricLoadReplicatorSettings( - codepackageactivationcontext: *mut core::ffi::c_void, - configurationpackagename: windows_core::PCWSTR, - sectionname: windows_core::PCWSTR, - replicatorsettings: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricLoadReplicatorSettings( - codepackageactivationcontext.param().abi(), - configurationpackagename.param().abi(), - sectionname.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn FabricLoadSecurityCredentials( - codepackageactivationcontext: P0, - configurationpackagename: P1, - sectionname: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricRuntime")] - extern "system" { - pub fn FabricLoadSecurityCredentials( - codepackageactivationcontext: *mut core::ffi::c_void, - configurationpackagename: windows_core::PCWSTR, - sectionname: windows_core::PCWSTR, - securitycredentials: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - FabricLoadSecurityCredentials( - codepackageactivationcontext.param().abi(), - configurationpackagename.param().abi(), - sectionname.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} windows_core::imp::define_interface!( IFabricAtomicGroupStateProvider, IFabricAtomicGroupStateProvider_Vtbl, diff --git a/crates/libs/com/src/ServiceFabric/FabricTransport.rs b/crates/libs/com/src/ServiceFabric/FabricTransport.rs deleted file mode 100644 index eafcd1d2..00000000 --- a/crates/libs/com/src/ServiceFabric/FabricTransport.rs +++ /dev/null @@ -1,1587 +0,0 @@ -// Bindings generated by `windows-bindgen` 0.58.0 - -#![allow( - non_snake_case, - non_upper_case_globals, - non_camel_case_types, - dead_code, - clippy::all -)] -#[inline] -pub unsafe fn CreateFabricTransportClient( - interfaceid: *const windows_core::GUID, - settings: *const FABRIC_TRANSPORT_SETTINGS, - connectionaddress: P0, - notificationhandler: P1, - clienteventhandler: P2, - messagedisposer: P3, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, - P3: windows_core::Param, -{ - #[link(name = "FabricTransport")] - extern "system" { - pub fn CreateFabricTransportClient( - interfaceid: *const windows_core::GUID, - settings: *const FABRIC_TRANSPORT_SETTINGS, - connectionaddress: windows_core::PCWSTR, - notificationhandler: *mut core::ffi::c_void, - clienteventhandler: *mut core::ffi::c_void, - messagedisposer: *mut core::ffi::c_void, - client: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - CreateFabricTransportClient( - interfaceid, - settings, - connectionaddress.param().abi(), - notificationhandler.param().abi(), - clienteventhandler.param().abi(), - messagedisposer.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -#[inline] -pub unsafe fn CreateFabricTransportListener( - interfaceid: *const windows_core::GUID, - settings: *const FABRIC_TRANSPORT_SETTINGS, - address: *const FABRIC_TRANSPORT_LISTEN_ADDRESS, - requesthandler: P0, - connectionhandler: P1, - disposeprocessor: P2, -) -> windows_core::Result -where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, -{ - #[link(name = "FabricTransport")] - extern "system" { - pub fn CreateFabricTransportListener( - interfaceid: *const windows_core::GUID, - settings: *const FABRIC_TRANSPORT_SETTINGS, - address: *const FABRIC_TRANSPORT_LISTEN_ADDRESS, - requesthandler: *mut core::ffi::c_void, - connectionhandler: *mut core::ffi::c_void, - disposeprocessor: *mut core::ffi::c_void, - listener: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT; - } - let mut result__ = core::mem::zeroed(); - CreateFabricTransportListener( - interfaceid, - settings, - address, - requesthandler.param().abi(), - connectionhandler.param().abi(), - disposeprocessor.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) -} -windows_core::imp::define_interface!( - IFabricTransportCallbackMessageHandler, - IFabricTransportCallbackMessageHandler_Vtbl, - 0x9ba8ac7a_3464_4774_b9b9_1d7f0f1920ba -); -impl core::ops::Deref for IFabricTransportCallbackMessageHandler { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!( - IFabricTransportCallbackMessageHandler, - windows_core::IUnknown -); -impl IFabricTransportCallbackMessageHandler { - pub unsafe fn HandleOneWay(&self, message: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).HandleOneWay)( - windows_core::Interface::as_raw(self), - message.param().abi(), - ) - .ok() - } -} -unsafe impl Send for IFabricTransportCallbackMessageHandler {} -unsafe impl Sync for IFabricTransportCallbackMessageHandler {} -#[repr(C)] -pub struct IFabricTransportCallbackMessageHandler_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub HandleOneWay: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IFabricTransportClient, - IFabricTransportClient_Vtbl, - 0x5b0634fe_6a52_4bd9_8059_892c72c1d73a -); -impl core::ops::Deref for IFabricTransportClient { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportClient, windows_core::IUnknown); -impl IFabricTransportClient { - pub unsafe fn BeginRequest( - &self, - message: P0, - timeoutmilliseconds: u32, - callback: P1, - ) -> windows_core::Result - where - P0: windows_core::Param, - P1: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginRequest)( - windows_core::Interface::as_raw(self), - message.param().abi(), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndRequest( - &self, - context: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).EndRequest)( - windows_core::Interface::as_raw(self), - context.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn Send(&self, message: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).Send)( - windows_core::Interface::as_raw(self), - message.param().abi(), - ) - .ok() - } - pub unsafe fn BeginOpen( - &self, - timeoutmilliseconds: u32, - callback: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginOpen)( - windows_core::Interface::as_raw(self), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndOpen(&self, context: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).EndOpen)( - windows_core::Interface::as_raw(self), - context.param().abi(), - ) - .ok() - } - pub unsafe fn BeginClose( - &self, - timeoutmilliseconds: u32, - callback: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginClose)( - windows_core::Interface::as_raw(self), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndClose(&self, context: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).EndClose)( - windows_core::Interface::as_raw(self), - context.param().abi(), - ) - .ok() - } - pub unsafe fn Abort(&self) { - (windows_core::Interface::vtable(self).Abort)(windows_core::Interface::as_raw(self)) - } -} -unsafe impl Send for IFabricTransportClient {} -unsafe impl Sync for IFabricTransportClient {} -#[repr(C)] -pub struct IFabricTransportClient_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub BeginRequest: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndRequest: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub Send: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub BeginOpen: unsafe extern "system" fn( - *mut core::ffi::c_void, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndOpen: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub BeginClose: unsafe extern "system" fn( - *mut core::ffi::c_void, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndClose: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub Abort: unsafe extern "system" fn(*mut core::ffi::c_void), -} -windows_core::imp::define_interface!( - IFabricTransportClientConnection, - IFabricTransportClientConnection_Vtbl, - 0xa54c17f7_fe94_4838_b14d_e9b5c258e2d0 -); -impl core::ops::Deref for IFabricTransportClientConnection { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportClientConnection, windows_core::IUnknown); -impl IFabricTransportClientConnection { - pub unsafe fn Send(&self, message: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).Send)( - windows_core::Interface::as_raw(self), - message.param().abi(), - ) - .ok() - } - pub unsafe fn get_ClientId(&self) -> *mut u16 { - (windows_core::Interface::vtable(self).get_ClientId)(windows_core::Interface::as_raw(self)) - } -} -unsafe impl Send for IFabricTransportClientConnection {} -unsafe impl Sync for IFabricTransportClientConnection {} -#[repr(C)] -pub struct IFabricTransportClientConnection_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub Send: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub get_ClientId: unsafe extern "system" fn(*mut core::ffi::c_void) -> *mut u16, -} -windows_core::imp::define_interface!( - IFabricTransportClientEventHandler, - IFabricTransportClientEventHandler_Vtbl, - 0x4935ab6f_a8bc_4b10_a69e_7a3ba3324892 -); -impl core::ops::Deref for IFabricTransportClientEventHandler { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportClientEventHandler, windows_core::IUnknown); -impl IFabricTransportClientEventHandler { - pub unsafe fn OnConnected(&self, connectionaddress: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).OnConnected)( - windows_core::Interface::as_raw(self), - connectionaddress.param().abi(), - ) - .ok() - } - pub unsafe fn OnDisconnected( - &self, - connectionaddress: P0, - error: windows_core::HRESULT, - ) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).OnDisconnected)( - windows_core::Interface::as_raw(self), - connectionaddress.param().abi(), - error, - ) - .ok() - } -} -unsafe impl Send for IFabricTransportClientEventHandler {} -unsafe impl Sync for IFabricTransportClientEventHandler {} -#[repr(C)] -pub struct IFabricTransportClientEventHandler_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub OnConnected: unsafe extern "system" fn( - *mut core::ffi::c_void, - windows_core::PCWSTR, - ) -> windows_core::HRESULT, - pub OnDisconnected: unsafe extern "system" fn( - *mut core::ffi::c_void, - windows_core::PCWSTR, - windows_core::HRESULT, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IFabricTransportConnectionHandler, - IFabricTransportConnectionHandler_Vtbl, - 0xb069692d_e8f0_4f25_a3b6_b2992598a64c -); -impl core::ops::Deref for IFabricTransportConnectionHandler { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportConnectionHandler, windows_core::IUnknown); -impl IFabricTransportConnectionHandler { - pub unsafe fn BeginProcessConnect( - &self, - clientconnection: P0, - timeoutmilliseconds: u32, - callback: P1, - ) -> windows_core::Result - where - P0: windows_core::Param, - P1: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginProcessConnect)( - windows_core::Interface::as_raw(self), - clientconnection.param().abi(), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndProcessConnect(&self, context: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).EndProcessConnect)( - windows_core::Interface::as_raw(self), - context.param().abi(), - ) - .ok() - } - pub unsafe fn BeginProcessDisconnect( - &self, - clientid: *const u16, - timeoutmilliseconds: u32, - callback: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginProcessDisconnect)( - windows_core::Interface::as_raw(self), - clientid, - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndProcessDisconnect(&self, context: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).EndProcessDisconnect)( - windows_core::Interface::as_raw(self), - context.param().abi(), - ) - .ok() - } -} -unsafe impl Send for IFabricTransportConnectionHandler {} -unsafe impl Sync for IFabricTransportConnectionHandler {} -#[repr(C)] -pub struct IFabricTransportConnectionHandler_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub BeginProcessConnect: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndProcessConnect: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub BeginProcessDisconnect: unsafe extern "system" fn( - *mut core::ffi::c_void, - *const u16, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndProcessDisconnect: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IFabricTransportListener, - IFabricTransportListener_Vtbl, - 0x1b63a266_1eeb_4f3e_8886_521458980d10 -); -impl core::ops::Deref for IFabricTransportListener { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportListener, windows_core::IUnknown); -impl IFabricTransportListener { - pub unsafe fn BeginOpen( - &self, - callback: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginOpen)( - windows_core::Interface::as_raw(self), - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndOpen( - &self, - context: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).EndOpen)( - windows_core::Interface::as_raw(self), - context.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn BeginClose( - &self, - callback: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginClose)( - windows_core::Interface::as_raw(self), - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndClose(&self, context: P0) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).EndClose)( - windows_core::Interface::as_raw(self), - context.param().abi(), - ) - .ok() - } - pub unsafe fn Abort(&self) { - (windows_core::Interface::vtable(self).Abort)(windows_core::Interface::as_raw(self)) - } -} -unsafe impl Send for IFabricTransportListener {} -unsafe impl Sync for IFabricTransportListener {} -#[repr(C)] -pub struct IFabricTransportListener_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub BeginOpen: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndOpen: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub BeginClose: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndClose: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub Abort: unsafe extern "system" fn(*mut core::ffi::c_void), -} -windows_core::imp::define_interface!( - IFabricTransportMessage, - IFabricTransportMessage_Vtbl, - 0xb4357dab_ef06_465f_b453_938f3b0ad4b5 -); -impl core::ops::Deref for IFabricTransportMessage { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportMessage, windows_core::IUnknown); -impl IFabricTransportMessage { - pub unsafe fn GetHeaderAndBodyBuffer( - &self, - headerbuffer: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - msgbuffercount: *mut u32, - msgbuffers: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - ) { - (windows_core::Interface::vtable(self).GetHeaderAndBodyBuffer)( - windows_core::Interface::as_raw(self), - headerbuffer, - msgbuffercount, - msgbuffers, - ) - } - pub unsafe fn Dispose(&self) { - (windows_core::Interface::vtable(self).Dispose)(windows_core::Interface::as_raw(self)) - } -} -unsafe impl Send for IFabricTransportMessage {} -unsafe impl Sync for IFabricTransportMessage {} -#[repr(C)] -pub struct IFabricTransportMessage_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub GetHeaderAndBodyBuffer: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - *mut u32, - *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - ), - pub Dispose: unsafe extern "system" fn(*mut core::ffi::c_void), -} -windows_core::imp::define_interface!( - IFabricTransportMessageDisposer, - IFabricTransportMessageDisposer_Vtbl, - 0x914097f3_a821_46ea_b3d9_feafe5f7c4a9 -); -impl core::ops::Deref for IFabricTransportMessageDisposer { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportMessageDisposer, windows_core::IUnknown); -impl IFabricTransportMessageDisposer { - pub unsafe fn Dispose(&self, messages: &[Option]) { - (windows_core::Interface::vtable(self).Dispose)( - windows_core::Interface::as_raw(self), - messages.len().try_into().unwrap(), - core::mem::transmute(messages.as_ptr()), - ) - } -} -unsafe impl Send for IFabricTransportMessageDisposer {} -unsafe impl Sync for IFabricTransportMessageDisposer {} -#[repr(C)] -pub struct IFabricTransportMessageDisposer_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub Dispose: - unsafe extern "system" fn(*mut core::ffi::c_void, u32, *const *mut core::ffi::c_void), -} -windows_core::imp::define_interface!( - IFabricTransportMessageHandler, - IFabricTransportMessageHandler_Vtbl, - 0x6815bdb4_1479_4c44_8b9d_57d6d0cc9d64 -); -impl core::ops::Deref for IFabricTransportMessageHandler { - type Target = windows_core::IUnknown; - fn deref(&self) -> &Self::Target { - unsafe { core::mem::transmute(self) } - } -} -windows_core::imp::interface_hierarchy!(IFabricTransportMessageHandler, windows_core::IUnknown); -impl IFabricTransportMessageHandler { - pub unsafe fn BeginProcessRequest( - &self, - clientid: *const u16, - message: P0, - timeoutmilliseconds: u32, - callback: P1, - ) -> windows_core::Result - where - P0: windows_core::Param, - P1: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).BeginProcessRequest)( - windows_core::Interface::as_raw(self), - clientid, - message.param().abi(), - timeoutmilliseconds, - callback.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn EndProcessRequest( - &self, - context: P0, - ) -> windows_core::Result - where - P0: windows_core::Param, - { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(self).EndProcessRequest)( - windows_core::Interface::as_raw(self), - context.param().abi(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - pub unsafe fn HandleOneWay( - &self, - clientid: *const u16, - message: P0, - ) -> windows_core::Result<()> - where - P0: windows_core::Param, - { - (windows_core::Interface::vtable(self).HandleOneWay)( - windows_core::Interface::as_raw(self), - clientid, - message.param().abi(), - ) - .ok() - } -} -unsafe impl Send for IFabricTransportMessageHandler {} -unsafe impl Sync for IFabricTransportMessageHandler {} -#[repr(C)] -pub struct IFabricTransportMessageHandler_Vtbl { - pub base__: windows_core::IUnknown_Vtbl, - pub BeginProcessRequest: unsafe extern "system" fn( - *mut core::ffi::c_void, - *const u16, - *mut core::ffi::c_void, - u32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub EndProcessRequest: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub HandleOneWay: unsafe extern "system" fn( - *mut core::ffi::c_void, - *const u16, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -#[repr(C)] -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct FABRIC_TRANSPORT_LISTEN_ADDRESS { - pub IPAddressOrFQDN: windows_core::PCWSTR, - pub Port: u32, - pub Path: windows_core::PCWSTR, -} -impl windows_core::TypeKind for FABRIC_TRANSPORT_LISTEN_ADDRESS { - type TypeKind = windows_core::CopyType; -} -impl Default for FABRIC_TRANSPORT_LISTEN_ADDRESS { - fn default() -> Self { - unsafe { core::mem::zeroed() } - } -} -#[repr(C)] -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct FABRIC_TRANSPORT_MESSAGE_BUFFER { - pub BufferSize: u32, - pub Buffer: *mut u8, -} -impl windows_core::TypeKind for FABRIC_TRANSPORT_MESSAGE_BUFFER { - type TypeKind = windows_core::CopyType; -} -impl Default for FABRIC_TRANSPORT_MESSAGE_BUFFER { - fn default() -> Self { - unsafe { core::mem::zeroed() } - } -} -#[repr(C)] -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct FABRIC_TRANSPORT_SETTINGS { - pub OperationTimeoutInSeconds: u32, - pub KeepAliveTimeoutInSeconds: u32, - pub MaxMessageSize: u32, - pub MaxConcurrentCalls: u32, - pub MaxQueueSize: u32, - pub SecurityCredentials: *const super::FabricTypes::FABRIC_SECURITY_CREDENTIALS, - pub Reserved: *mut core::ffi::c_void, -} -impl windows_core::TypeKind for FABRIC_TRANSPORT_SETTINGS { - type TypeKind = windows_core::CopyType; -} -impl Default for FABRIC_TRANSPORT_SETTINGS { - fn default() -> Self { - unsafe { core::mem::zeroed() } - } -} -pub trait IFabricTransportCallbackMessageHandler_Impl: Sized { - fn HandleOneWay(&self, message: Option<&IFabricTransportMessage>) -> windows_core::Result<()>; -} -impl windows_core::RuntimeName for IFabricTransportCallbackMessageHandler {} -impl IFabricTransportCallbackMessageHandler_Vtbl { - pub const fn new( - ) -> IFabricTransportCallbackMessageHandler_Vtbl - where - Identity: IFabricTransportCallbackMessageHandler_Impl, - { - unsafe extern "system" fn HandleOneWay< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - message: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportCallbackMessageHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportCallbackMessageHandler_Impl::HandleOneWay( - this, - windows_core::from_raw_borrowed(&message), - ) - .into() - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - HandleOneWay: HandleOneWay::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportClient_Impl: Sized { - fn BeginRequest( - &self, - message: Option<&IFabricTransportMessage>, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndRequest( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result; - fn Send(&self, message: Option<&IFabricTransportMessage>) -> windows_core::Result<()>; - fn BeginOpen( - &self, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndOpen( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result<()>; - fn BeginClose( - &self, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndClose( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result<()>; - fn Abort(&self); -} -impl windows_core::RuntimeName for IFabricTransportClient {} -impl IFabricTransportClient_Vtbl { - pub const fn new( - ) -> IFabricTransportClient_Vtbl - where - Identity: IFabricTransportClient_Impl, - { - unsafe extern "system" fn BeginRequest< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - message: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportClient_Impl::BeginRequest( - this, - windows_core::from_raw_borrowed(&message), - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndRequest< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - reply: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportClient_Impl::EndRequest( - this, - windows_core::from_raw_borrowed(&context), - ) { - Ok(ok__) => { - reply.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn Send( - this: *mut core::ffi::c_void, - message: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClient_Impl::Send(this, windows_core::from_raw_borrowed(&message)) - .into() - } - unsafe extern "system" fn BeginOpen< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportClient_Impl::BeginOpen( - this, - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndOpen< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClient_Impl::EndOpen(this, windows_core::from_raw_borrowed(&context)) - .into() - } - unsafe extern "system" fn BeginClose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportClient_Impl::BeginClose( - this, - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndClose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClient_Impl::EndClose(this, windows_core::from_raw_borrowed(&context)) - .into() - } - unsafe extern "system" fn Abort( - this: *mut core::ffi::c_void, - ) where - Identity: IFabricTransportClient_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClient_Impl::Abort(this) - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - BeginRequest: BeginRequest::, - EndRequest: EndRequest::, - Send: Send::, - BeginOpen: BeginOpen::, - EndOpen: EndOpen::, - BeginClose: BeginClose::, - EndClose: EndClose::, - Abort: Abort::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportClientConnection_Impl: Sized { - fn Send(&self, message: Option<&IFabricTransportMessage>) -> windows_core::Result<()>; - fn get_ClientId(&self) -> *mut u16; -} -impl windows_core::RuntimeName for IFabricTransportClientConnection {} -impl IFabricTransportClientConnection_Vtbl { - pub const fn new( - ) -> IFabricTransportClientConnection_Vtbl - where - Identity: IFabricTransportClientConnection_Impl, - { - unsafe extern "system" fn Send( - this: *mut core::ffi::c_void, - message: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClientConnection_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClientConnection_Impl::Send( - this, - windows_core::from_raw_borrowed(&message), - ) - .into() - } - unsafe extern "system" fn get_ClientId< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - ) -> *mut u16 - where - Identity: IFabricTransportClientConnection_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClientConnection_Impl::get_ClientId(this) - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - Send: Send::, - get_ClientId: get_ClientId::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportClientEventHandler_Impl: Sized { - fn OnConnected(&self, connectionaddress: &windows_core::PCWSTR) -> windows_core::Result<()>; - fn OnDisconnected( - &self, - connectionaddress: &windows_core::PCWSTR, - error: windows_core::HRESULT, - ) -> windows_core::Result<()>; -} -impl windows_core::RuntimeName for IFabricTransportClientEventHandler {} -impl IFabricTransportClientEventHandler_Vtbl { - pub const fn new( - ) -> IFabricTransportClientEventHandler_Vtbl - where - Identity: IFabricTransportClientEventHandler_Impl, - { - unsafe extern "system" fn OnConnected< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - connectionaddress: windows_core::PCWSTR, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClientEventHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClientEventHandler_Impl::OnConnected( - this, - core::mem::transmute(&connectionaddress), - ) - .into() - } - unsafe extern "system" fn OnDisconnected< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - connectionaddress: windows_core::PCWSTR, - error: windows_core::HRESULT, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportClientEventHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportClientEventHandler_Impl::OnDisconnected( - this, - core::mem::transmute(&connectionaddress), - core::mem::transmute_copy(&error), - ) - .into() - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - OnConnected: OnConnected::, - OnDisconnected: OnDisconnected::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportConnectionHandler_Impl: Sized { - fn BeginProcessConnect( - &self, - clientconnection: Option<&IFabricTransportClientConnection>, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndProcessConnect( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result<()>; - fn BeginProcessDisconnect( - &self, - clientid: *const u16, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndProcessDisconnect( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result<()>; -} -impl windows_core::RuntimeName for IFabricTransportConnectionHandler {} -impl IFabricTransportConnectionHandler_Vtbl { - pub const fn new( - ) -> IFabricTransportConnectionHandler_Vtbl - where - Identity: IFabricTransportConnectionHandler_Impl, - { - unsafe extern "system" fn BeginProcessConnect< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - clientconnection: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportConnectionHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportConnectionHandler_Impl::BeginProcessConnect( - this, - windows_core::from_raw_borrowed(&clientconnection), - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndProcessConnect< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportConnectionHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportConnectionHandler_Impl::EndProcessConnect( - this, - windows_core::from_raw_borrowed(&context), - ) - .into() - } - unsafe extern "system" fn BeginProcessDisconnect< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - clientid: *const u16, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportConnectionHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportConnectionHandler_Impl::BeginProcessDisconnect( - this, - core::mem::transmute_copy(&clientid), - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndProcessDisconnect< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportConnectionHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportConnectionHandler_Impl::EndProcessDisconnect( - this, - windows_core::from_raw_borrowed(&context), - ) - .into() - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - BeginProcessConnect: BeginProcessConnect::, - EndProcessConnect: EndProcessConnect::, - BeginProcessDisconnect: BeginProcessDisconnect::, - EndProcessDisconnect: EndProcessDisconnect::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportListener_Impl: Sized { - fn BeginOpen( - &self, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndOpen( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result; - fn BeginClose( - &self, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndClose( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result<()>; - fn Abort(&self); -} -impl windows_core::RuntimeName for IFabricTransportListener {} -impl IFabricTransportListener_Vtbl { - pub const fn new( - ) -> IFabricTransportListener_Vtbl - where - Identity: IFabricTransportListener_Impl, - { - unsafe extern "system" fn BeginOpen< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportListener_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportListener_Impl::BeginOpen( - this, - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndOpen< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - serviceaddress: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportListener_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportListener_Impl::EndOpen( - this, - windows_core::from_raw_borrowed(&context), - ) { - Ok(ok__) => { - serviceaddress.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn BeginClose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportListener_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportListener_Impl::BeginClose( - this, - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndClose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportListener_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportListener_Impl::EndClose(this, windows_core::from_raw_borrowed(&context)) - .into() - } - unsafe extern "system" fn Abort( - this: *mut core::ffi::c_void, - ) where - Identity: IFabricTransportListener_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportListener_Impl::Abort(this) - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - BeginOpen: BeginOpen::, - EndOpen: EndOpen::, - BeginClose: BeginClose::, - EndClose: EndClose::, - Abort: Abort::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportMessage_Impl: Sized { - fn GetHeaderAndBodyBuffer( - &self, - headerbuffer: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - msgbuffercount: *mut u32, - msgbuffers: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - ); - fn Dispose(&self); -} -impl windows_core::RuntimeName for IFabricTransportMessage {} -impl IFabricTransportMessage_Vtbl { - pub const fn new( - ) -> IFabricTransportMessage_Vtbl - where - Identity: IFabricTransportMessage_Impl, - { - unsafe extern "system" fn GetHeaderAndBodyBuffer< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - headerbuffer: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - msgbuffercount: *mut u32, - msgbuffers: *mut *mut FABRIC_TRANSPORT_MESSAGE_BUFFER, - ) where - Identity: IFabricTransportMessage_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportMessage_Impl::GetHeaderAndBodyBuffer( - this, - core::mem::transmute_copy(&headerbuffer), - core::mem::transmute_copy(&msgbuffercount), - core::mem::transmute_copy(&msgbuffers), - ) - } - unsafe extern "system" fn Dispose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - ) where - Identity: IFabricTransportMessage_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportMessage_Impl::Dispose(this) - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - GetHeaderAndBodyBuffer: GetHeaderAndBodyBuffer::, - Dispose: Dispose::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportMessageDisposer_Impl: Sized { - fn Dispose(&self, count: u32, messages: *const Option); -} -impl windows_core::RuntimeName for IFabricTransportMessageDisposer {} -impl IFabricTransportMessageDisposer_Vtbl { - pub const fn new( - ) -> IFabricTransportMessageDisposer_Vtbl - where - Identity: IFabricTransportMessageDisposer_Impl, - { - unsafe extern "system" fn Dispose< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - count: u32, - messages: *const *mut core::ffi::c_void, - ) where - Identity: IFabricTransportMessageDisposer_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportMessageDisposer_Impl::Dispose( - this, - core::mem::transmute_copy(&count), - core::mem::transmute_copy(&messages), - ) - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - Dispose: Dispose::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -pub trait IFabricTransportMessageHandler_Impl: Sized { - fn BeginProcessRequest( - &self, - clientid: *const u16, - message: Option<&IFabricTransportMessage>, - timeoutmilliseconds: u32, - callback: Option<&super::FabricCommon::IFabricAsyncOperationCallback>, - ) -> windows_core::Result; - fn EndProcessRequest( - &self, - context: Option<&super::FabricCommon::IFabricAsyncOperationContext>, - ) -> windows_core::Result; - fn HandleOneWay( - &self, - clientid: *const u16, - message: Option<&IFabricTransportMessage>, - ) -> windows_core::Result<()>; -} -impl windows_core::RuntimeName for IFabricTransportMessageHandler {} -impl IFabricTransportMessageHandler_Vtbl { - pub const fn new( - ) -> IFabricTransportMessageHandler_Vtbl - where - Identity: IFabricTransportMessageHandler_Impl, - { - unsafe extern "system" fn BeginProcessRequest< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - clientid: *const u16, - message: *mut core::ffi::c_void, - timeoutmilliseconds: u32, - callback: *mut core::ffi::c_void, - context: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportMessageHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportMessageHandler_Impl::BeginProcessRequest( - this, - core::mem::transmute_copy(&clientid), - windows_core::from_raw_borrowed(&message), - core::mem::transmute_copy(&timeoutmilliseconds), - windows_core::from_raw_borrowed(&callback), - ) { - Ok(ok__) => { - context.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn EndProcessRequest< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - context: *mut core::ffi::c_void, - reply: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportMessageHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - match IFabricTransportMessageHandler_Impl::EndProcessRequest( - this, - windows_core::from_raw_borrowed(&context), - ) { - Ok(ok__) => { - reply.write(core::mem::transmute(ok__)); - windows_core::HRESULT(0) - } - Err(err) => err.into(), - } - } - unsafe extern "system" fn HandleOneWay< - Identity: windows_core::IUnknownImpl, - const OFFSET: isize, - >( - this: *mut core::ffi::c_void, - clientid: *const u16, - message: *mut core::ffi::c_void, - ) -> windows_core::HRESULT - where - Identity: IFabricTransportMessageHandler_Impl, - { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IFabricTransportMessageHandler_Impl::HandleOneWay( - this, - core::mem::transmute_copy(&clientid), - windows_core::from_raw_borrowed(&message), - ) - .into() - } - Self { - base__: windows_core::IUnknown_Vtbl::new::(), - BeginProcessRequest: BeginProcessRequest::, - EndProcessRequest: EndProcessRequest::, - HandleOneWay: HandleOneWay::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} diff --git a/crates/libs/com/src/ServiceFabric/mod.rs b/crates/libs/com/src/ServiceFabric/mod.rs index ac4161d8..5b0a639f 100644 --- a/crates/libs/com/src/ServiceFabric/mod.rs +++ b/crates/libs/com/src/ServiceFabric/mod.rs @@ -6,5 +6,4 @@ pub mod FabricClient; pub mod FabricCommon; pub mod FabricRuntime; -pub mod FabricTransport; pub mod FabricTypes; diff --git a/crates/libs/com/src/lib.rs b/crates/libs/com/src/lib.rs index 92d79f35..81ecce1c 100644 --- a/crates/libs/com/src/lib.rs +++ b/crates/libs/com/src/lib.rs @@ -11,8 +11,8 @@ pub mod ServiceFabric; // expose mod directly pub use ServiceFabric::*; -#[cfg(all(target_os = "windows", feature = "bundled_libs"))] -pub use mssf_metadata; +// #[cfg(all(target_os = "windows", feature = "bundled_libs"))] +// pub use mssf_metadata; // Special usage for mssf_pal. // See mssf_pal documentations for why this is used this way. diff --git a/crates/libs/core/Cargo.toml b/crates/libs/core/Cargo.toml index 505c5c61..2c59eb70 100644 --- a/crates/libs/core/Cargo.toml +++ b/crates/libs/core/Cargo.toml @@ -30,6 +30,8 @@ ctrlc = { version = "3", features = ["termination"], optional = true } trait-variant = "0.1" bitflags = "2" config = { version = "0.14", default-features = false, optional = true } +libloading = "0.8" +lazy_static = "1" [dev-dependencies] paste = "1" diff --git a/crates/libs/core/src/api/mod.rs b/crates/libs/core/src/api/mod.rs new file mode 100644 index 00000000..863bde8a --- /dev/null +++ b/crates/libs/core/src/api/mod.rs @@ -0,0 +1,317 @@ +//! Dynamically load SF libs and c functions. +//! SF shared lib provides these functions, and we dynamically load them here so that user of this crate +//! does not need to worry about installing SF lib and linking, which can be complex. +//! + +use mssf_com::{ + FabricClient::{IFabricClientConnectionEventHandler, IFabricServiceNotificationEventHandler}, + FabricCommon::{ + IFabricAsyncOperationCallback, IFabricAsyncOperationContext, IFabricStringResult, + }, + FabricRuntime::IFabricStoreEventHandler, + FabricTypes::{FABRIC_CLIENT_ROLE, FABRIC_LOCAL_STORE_KIND, FABRIC_REPLICATOR_SETTINGS}, +}; +use windows_core::{Interface, Param}; + +lazy_static::lazy_static! { + static ref LIB_TABLE: LibTable = LibTable::create(); + pub static ref API_TABLE: ApiTable = ApiTable::create(&LIB_TABLE); +} + +pub struct LibTable { + fabric_runtime: libloading::Library, + fabric_common: libloading::Library, + fabric_client: libloading::Library, +} + +impl LibTable { + fn create() -> Self { + Self { + fabric_runtime: load_lib("FabricRuntime"), + fabric_common: load_lib("FabricCommon"), + fabric_client: load_lib("FabricClient"), + } + } +} + +fn load_lib(name: &str) -> libloading::Library { + unsafe { libloading::Library::new(libloading::library_filename(name)) } + .unwrap_or_else(|e| panic!("cannot load lib {name} :{e}")) +} + +fn load_fn(lib: &'static libloading::Library, name: &str) -> libloading::Symbol<'static, T> { + unsafe { lib.get(name.as_bytes()) }.unwrap_or_else(|e| panic!("cannot load fn {name} :{e}")) +} + +pub struct ApiTable { + fabric_get_last_error_message_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn(message: *mut *mut core::ffi::c_void) -> crate::HRESULT, + >, + fabric_create_client3_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + connectionstringssize: u16, + connectionstrings: *const windows_core::PCWSTR, + __midl__fabricclientmodule0002: *mut core::ffi::c_void, + __midl__fabricclientmodule0003: *mut core::ffi::c_void, + iid: *const windows_core::GUID, + fabricclient: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + fabric_create_local_client3_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + __midl__fabricclientmodule0004: *mut core::ffi::c_void, + __midl__fabricclientmodule0005: *mut core::ffi::c_void, + iid: *const windows_core::GUID, + fabricclient: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + + fabric_create_local_client4_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + __midl__fabricclientmodule0006: *mut core::ffi::c_void, + __midl__fabricclientmodule0007: *mut core::ffi::c_void, + clientrole: FABRIC_CLIENT_ROLE, + iid: *const windows_core::GUID, + fabricclient: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + + fabric_create_runtime_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + riid: *const windows_core::GUID, + fabricruntime: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + + fabric_get_activation_context_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + riid: *const windows_core::GUID, + activationcontext: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + + fabric_begin_get_node_context_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + timeoutmilliseconds: u32, + callback: *mut core::ffi::c_void, + context: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + + fabric_end_get_node_context_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + context: *mut core::ffi::c_void, + nodecontext: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, + fabric_get_node_context_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn(nodecontext: *mut *mut core::ffi::c_void) -> crate::HRESULT, + >, + fabric_create_key_value_store_replica_fn: libloading::Symbol< + 'static, + unsafe extern "system" fn( + riid: *const windows_core::GUID, + storename: windows_core::PCWSTR, + partitionid: windows_core::GUID, + replicaid: i64, + replicatorsettings: *const FABRIC_REPLICATOR_SETTINGS, + localstorekind: FABRIC_LOCAL_STORE_KIND, + localstoresettings: *const core::ffi::c_void, + storeeventhandler: *mut core::ffi::c_void, + keyvaluestore: *mut *mut core::ffi::c_void, + ) -> crate::HRESULT, + >, +} + +impl ApiTable { + fn create(lib_table: &'static LibTable) -> Self { + Self { + fabric_get_last_error_message_fn: load_fn( + &lib_table.fabric_common, + "FabricGetLastErrorMessage", + ), + fabric_create_client3_fn: load_fn(&lib_table.fabric_client, "FabricCreateClient3"), + fabric_create_local_client3_fn: load_fn( + &lib_table.fabric_client, + "FabricCreateLocalClient3", + ), + fabric_create_local_client4_fn: load_fn( + &lib_table.fabric_client, + "FabricCreateLocalClient4", + ), + fabric_create_runtime_fn: load_fn(&lib_table.fabric_runtime, "FabricCreateRuntime"), + fabric_get_activation_context_fn: load_fn( + &lib_table.fabric_runtime, + "FabricGetActivationContext", + ), + fabric_begin_get_node_context_fn: load_fn( + &lib_table.fabric_runtime, + "FabricBeginGetNodeContext", + ), + fabric_end_get_node_context_fn: load_fn( + &lib_table.fabric_runtime, + "FabricEndGetNodeContext", + ), + fabric_get_node_context_fn: load_fn(&lib_table.fabric_runtime, "FabricGetNodeContext"), + fabric_create_key_value_store_replica_fn: load_fn( + &lib_table.fabric_runtime, + "FabricCreateKeyValueStoreReplica", + ), + } + } + + pub fn fabric_get_last_error_message(&self) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { (self.fabric_get_last_error_message_fn)(std::ptr::addr_of_mut!(result)) }.ok()?; + assert!(!result.is_null()); + Ok(unsafe { IFabricStringResult::from_raw(result) }) + } + + pub fn fabric_create_client3( + &self, + connectionstrings: &[windows_core::PCWSTR], + service_notification_handler: Option<&IFabricServiceNotificationEventHandler>, + client_connection_handler: Option<&IFabricClientConnectionEventHandler>, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_create_client3_fn)( + connectionstrings.len().try_into().unwrap(), + connectionstrings.as_ptr(), + service_notification_handler.param().abi(), + client_connection_handler.param().abi(), + &T::IID, + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_create_local_client3( + &self, + service_notification_handler: Option<&IFabricServiceNotificationEventHandler>, + client_connection_handler: Option<&IFabricClientConnectionEventHandler>, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_create_local_client3_fn)( + service_notification_handler.param().abi(), + client_connection_handler.param().abi(), + &T::IID, + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_create_local_client4( + &self, + service_notification_handler: Option<&IFabricServiceNotificationEventHandler>, + client_connection_handler: Option<&IFabricClientConnectionEventHandler>, + clientrole: FABRIC_CLIENT_ROLE, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_create_local_client4_fn)( + service_notification_handler.param().abi(), + client_connection_handler.param().abi(), + clientrole, + &T::IID, + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_create_runtime(&self) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { (self.fabric_create_runtime_fn)(&T::IID, std::ptr::addr_of_mut!(result)) }.ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_get_activation_context(&self) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { (self.fabric_get_activation_context_fn)(&T::IID, std::ptr::addr_of_mut!(result)) } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_begin_get_node_context( + &self, + timeoutmilliseconds: u32, + callback: Option<&IFabricAsyncOperationCallback>, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_begin_get_node_context_fn)( + timeoutmilliseconds, + callback.param().abi(), + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { IFabricAsyncOperationContext::from_raw(result) }) + } + + pub fn fabric_end_get_node_context( + &self, + context: Option<&IFabricAsyncOperationContext>, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_end_get_node_context_fn)( + context.param().abi(), + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + pub fn fabric_get_node_context(&self) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { (self.fabric_get_node_context_fn)(std::ptr::addr_of_mut!(result)) }.ok()?; + Ok(unsafe { T::from_raw(result) }) + } + + #[allow(clippy::too_many_arguments)] + pub fn fabric_create_key_value_store_replica( + &self, + storename: windows_core::PCWSTR, + partitionid: windows_core::GUID, + replicaid: i64, + replicatorsettings: *const FABRIC_REPLICATOR_SETTINGS, + localstorekind: FABRIC_LOCAL_STORE_KIND, + localstoresettings: *const core::ffi::c_void, + storeeventhandler: Option<&IFabricStoreEventHandler>, + ) -> crate::Result { + let mut result = std::ptr::null_mut::(); + unsafe { + (self.fabric_create_key_value_store_replica_fn)( + &T::IID, + storename, + partitionid, + replicaid, + replicatorsettings, + localstorekind, + localstoresettings, + storeeventhandler.param().abi(), + std::ptr::addr_of_mut!(result), + ) + } + .ok()?; + Ok(unsafe { T::from_raw(result) }) + } +} diff --git a/crates/libs/core/src/client/mod.rs b/crates/libs/core/src/client/mod.rs index 0d38165e..31164ca8 100644 --- a/crates/libs/core/src/client/mod.rs +++ b/crates/libs/core/src/client/mod.rs @@ -5,7 +5,6 @@ use connection::{ClientConnectionEventHandlerBridge, LambdaClientConnectionNotificationHandler}; use mssf_com::FabricClient::{ - FabricCreateClient3, FabricCreateLocalClient3, FabricCreateLocalClient4, IFabricClientConnectionEventHandler, IFabricPropertyManagementClient2, IFabricQueryClient10, IFabricServiceManagementClient6, IFabricServiceNotificationEventHandler, }; @@ -48,45 +47,36 @@ fn create_local_client_internal( .collect::>() }); - let raw = match connection_strings_ptrs { - Some(addrs) => unsafe { + match connection_strings_ptrs { + Some(addrs) => { assert!( role == ClientRole::Unknown, "ClientRole is for local client only and cannot be used for connecting to remote cluster." ); - FabricCreateClient3( + crate::API_TABLE.fabric_create_client3::( &addrs, service_notification_handler, client_connection_handler, - &T::IID, ) }, None => { if role == ClientRole::Unknown { // unknown role should use the SF function without role param. - unsafe { - FabricCreateLocalClient3( + crate::API_TABLE.fabric_create_local_client3::( service_notification_handler, client_connection_handler, - &T::IID, ) - } } else { - unsafe { - FabricCreateLocalClient4( + crate::API_TABLE.fabric_create_local_client4::( service_notification_handler, client_connection_handler, role.into(), - &T::IID, ) - } } } } - .expect("failed to create fabric client"); - // if params are right, client should be created. There is no network call involved during obj creation. - unsafe { T::from_raw(raw) } + .expect("failed to create fabric client") } // Builder for FabricClient diff --git a/crates/libs/core/src/lib.rs b/crates/libs/core/src/lib.rs index 27ed8829..5375a189 100644 --- a/crates/libs/core/src/lib.rs +++ b/crates/libs/core/src/lib.rs @@ -19,6 +19,8 @@ // lib that contains all common extensions for the raw fabric apis. +pub mod api; +pub use api::API_TABLE; #[cfg(feature = "tokio_async")] pub mod client; #[cfg(feature = "config_source")] diff --git a/crates/libs/core/src/runtime/error.rs b/crates/libs/core/src/runtime/error.rs index 15fcd5b9..af8845d2 100644 --- a/crates/libs/core/src/runtime/error.rs +++ b/crates/libs/core/src/runtime/error.rs @@ -4,14 +4,13 @@ // ------------------------------------------------------------ use crate::{Error, WString, HRESULT}; -use mssf_com::FabricCommon::FabricGetLastErrorMessage; // Fills the error info as string for better debugging. // SF has separate last error set and get from windows. // Not all error strings are set by SF. This is not very useful in practice. pub fn fill_fabric_hresult(code: HRESULT) -> Error { // in rs, this function always succeed. The fail case is that the return ptr is null. - let sf_err = unsafe { FabricGetLastErrorMessage() }.unwrap(); + let sf_err = crate::API_TABLE.fabric_get_last_error_message().unwrap(); let err_str_raw = unsafe { sf_err.get_String() }; let err_str = if err_str_raw.is_null() { &[] diff --git a/crates/libs/core/src/runtime/mod.rs b/crates/libs/core/src/runtime/mod.rs index cb341f54..4794bb4d 100644 --- a/crates/libs/core/src/runtime/mod.rs +++ b/crates/libs/core/src/runtime/mod.rs @@ -3,11 +3,10 @@ // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ -use crate::Interface; -use mssf_com::FabricRuntime::{FabricCreateRuntime, FabricGetActivationContext, IFabricRuntime}; - #[cfg(feature = "tokio_async")] use mssf_com::FabricCommon::{IFabricAsyncOperationCallback, IFabricAsyncOperationContext}; +use mssf_com::FabricRuntime::IFabricRuntime; +use windows_core::Interface; #[cfg(feature = "tokio_async")] pub use self::runtime_wrapper::Runtime; @@ -39,14 +38,9 @@ pub use activation_context::{CodePackageActivationContext, CodePackageInfo}; // creates fabric runtime pub fn create_com_runtime() -> crate::Result { - let rawruntime = unsafe { FabricCreateRuntime(&IFabricRuntime::IID)? }; - let runtime = unsafe { IFabricRuntime::from_raw(rawruntime) }; - Ok(runtime) + crate::API_TABLE.fabric_create_runtime() } pub fn get_com_activation_context() -> crate::Result { - let raw_activation_ctx = unsafe { FabricGetActivationContext(&T::IID)? }; - - let activation_ctx = unsafe { T::from_raw(raw_activation_ctx) }; - Ok(activation_ctx) + crate::API_TABLE.fabric_get_activation_context::() } diff --git a/crates/libs/core/src/runtime/node_context.rs b/crates/libs/core/src/runtime/node_context.rs index 7a75c330..cf4df684 100644 --- a/crates/libs/core/src/runtime/node_context.rs +++ b/crates/libs/core/src/runtime/node_context.rs @@ -1,10 +1,7 @@ use std::time::Duration; use crate::{Interface, WString}; -use mssf_com::FabricRuntime::{ - FabricBeginGetNodeContext, FabricEndGetNodeContext, FabricGetNodeContext, - IFabricNodeContextResult, IFabricNodeContextResult2, -}; +use mssf_com::FabricRuntime::{IFabricNodeContextResult, IFabricNodeContextResult2}; use crate::{ strings::WStringWrap, @@ -17,13 +14,10 @@ pub fn get_com_node_context( cancellation_token: Option, ) -> crate::sync::FabricReceiver2<::windows_core::Result> { fabric_begin_end_proxy2( - move |callback| unsafe { FabricBeginGetNodeContext(timeout_milliseconds, callback) }, - move |ctx| { - unsafe { FabricEndGetNodeContext(ctx) }.map(|raw| { - assert!(!raw.is_null()); - unsafe { IFabricNodeContextResult::from_raw(raw) } - }) + move |callback| { + crate::API_TABLE.fabric_begin_get_node_context(timeout_milliseconds, callback) }, + move |ctx| crate::API_TABLE.fabric_end_get_node_context(ctx), cancellation_token, ) } @@ -51,9 +45,7 @@ impl NodeContext { // Get the node context synchronously pub fn get_sync() -> crate::Result { - let raw = unsafe { FabricGetNodeContext() }?; - assert!(!raw.is_null()); - let com = unsafe { IFabricNodeContextResult::from_raw(raw) }; + let com = crate::API_TABLE.fabric_get_node_context()?; Ok(Self::from(&com)) } diff --git a/crates/libs/core/src/runtime/store.rs b/crates/libs/core/src/runtime/store.rs index 6ba18dff..d18b6c08 100644 --- a/crates/libs/core/src/runtime/store.rs +++ b/crates/libs/core/src/runtime/store.rs @@ -5,11 +5,10 @@ use std::ffi::c_void; -use crate::{Interface, WString, PCWSTR}; +use crate::{WString, PCWSTR}; use mssf_com::{ FabricRuntime::{ - FabricCreateKeyValueStoreReplica, IFabricKeyValueStoreReplica2, IFabricStoreEventHandler, - IFabricStoreEventHandler_Impl, + IFabricKeyValueStoreReplica2, IFabricStoreEventHandler, IFabricStoreEventHandler_Impl, }, FabricTypes::{FABRIC_ESE_LOCAL_STORE_SETTINGS, FABRIC_LOCAL_STORE_KIND}, }; @@ -44,19 +43,13 @@ pub fn create_com_key_value_store_replica( Some(x) => &x, None => std::ptr::null(), }; - - // let handler:IFabricStoreEventHandler = DummyStoreEventHandler{}.into(); - let raw = unsafe { - FabricCreateKeyValueStoreReplica( - &IFabricKeyValueStoreReplica2::IID, - PCWSTR::from_raw(storename.as_ptr()), - partitionid, - replicaid, - &replicatorsettings.get_raw(), - kind, - local_settings_ptr as *const c_void, - storeeventhandler, - )? - }; - Ok(unsafe { IFabricKeyValueStoreReplica2::from_raw(raw) }) + crate::API_TABLE.fabric_create_key_value_store_replica::( + PCWSTR::from_raw(storename.as_ptr()), + partitionid, + replicaid, + &replicatorsettings.get_raw(), + kind, + local_settings_ptr as *const c_void, + Some(storeeventhandler), + ) } diff --git a/crates/libs/core/src/sync/cancel.rs b/crates/libs/core/src/sync/cancel.rs index e3fa9e86..098a7263 100644 --- a/crates/libs/core/src/sync/cancel.rs +++ b/crates/libs/core/src/sync/cancel.rs @@ -547,7 +547,8 @@ mod test { if delay.is_zero() { // This is needed to make future is breakable in bench test in select tokio::task::yield_now().await; - return Ok(self.set_data(input)); + self.set_data(input); + return Ok(()); } match token { Some(t) => { @@ -557,13 +558,15 @@ mod test { Err(FabricErrorCode::E_ABORT.into()) } _ = tokio::time::sleep(delay) => { - Ok(self.set_data(input)) + self.set_data(input); + Ok(()) } } } None => { tokio::time::sleep(delay).await; - Ok(self.set_data(input)) + self.set_data(input); + Ok(()) } } } diff --git a/crates/libs/core/src/sync/mod.rs b/crates/libs/core/src/sync/mod.rs index 12b607ab..2de79ab6 100644 --- a/crates/libs/core/src/sync/mod.rs +++ b/crates/libs/core/src/sync/mod.rs @@ -412,7 +412,7 @@ mod tests { let result = c.get_node_list_example(querydescription).await; - assert!(!result.is_err()); + assert!(result.is_ok()); let result_node_list = result.expect("endcall_failed"); diff --git a/crates/samples/client/src/main.rs b/crates/samples/client/src/main.rs index 666c9696..63b10db4 100644 --- a/crates/samples/client/src/main.rs +++ b/crates/samples/client/src/main.rs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ -use mssf_com::FabricClient::{FabricCreateLocalClient, IFabricQueryClient}; +use mssf_com::FabricClient::IFabricQueryClient; use mssf_com::FabricCommon::IFabricAsyncOperationCallback; use mssf_com::FabricTypes::{FABRIC_NODE_QUERY_DESCRIPTION, FABRIC_NODE_QUERY_RESULT_ITEM}; use mssf_core::sync::wait::WaitableCallback; @@ -12,11 +12,9 @@ use windows_core::Interface; fn main() -> mssf_core::Result<()> { println!("GetNodeCli"); - let rawclient = unsafe { - FabricCreateLocalClient(&IFabricQueryClient::IID).expect("cannot get localclient") - }; - // todo: figure out owner ship - let c: IFabricQueryClient = unsafe { IFabricQueryClient::from_raw(rawclient) }; + let c: IFabricQueryClient = mssf_core::API_TABLE + .fabric_create_local_client3::(None, None) + .expect("cannot get localclient"); let (token, callback) = WaitableCallback::channel(); diff --git a/crates/samples/echomain-stateful/src/main.rs b/crates/samples/echomain-stateful/src/main.rs index 851f328d..e02bdb47 100644 --- a/crates/samples/echomain-stateful/src/main.rs +++ b/crates/samples/echomain-stateful/src/main.rs @@ -5,9 +5,7 @@ use mssf_com::FabricCommon::IFabricAsyncOperationCallback; use mssf_com::FabricRuntime::{ - FabricBeginGetNodeContext, FabricCreateRuntime, FabricEndGetNodeContext, - FabricGetActivationContext, IFabricCodePackageActivationContext, IFabricNodeContextResult, - IFabricRuntime, + IFabricCodePackageActivationContext, IFabricNodeContextResult, IFabricRuntime, }; use mssf_core::sync::wait::WaitableCallback; use mssf_core::{Interface, WString}; @@ -27,17 +25,13 @@ fn main() -> mssf_core::Result<()> { // std::thread::sleep(std::time::Duration::from_secs(90)); // info!("sleep ended"); - let rawruntime = - unsafe { FabricCreateRuntime(&IFabricRuntime::IID).expect("cannot create runtime") }; - let runtime = unsafe { IFabricRuntime::from_raw(rawruntime) }; + let runtime = mssf_core::API_TABLE + .fabric_create_runtime() + .expect("cannot create fabric runtime"); - let raw_activation_ctx = unsafe { - FabricGetActivationContext(&IFabricCodePackageActivationContext::IID) - .expect("Cannot get activation ctx") - }; - - let activation_ctx = - unsafe { IFabricCodePackageActivationContext::from_raw(raw_activation_ctx) }; + let activation_ctx = mssf_core::API_TABLE + .fabric_get_activation_context() + .expect("cannot get activation context"); run_app(&runtime, &activation_ctx); @@ -70,13 +64,15 @@ fn get_hostname() -> WString { let callback_arg = callback .cast::() .expect("castfailed"); - let ctx = unsafe { FabricBeginGetNodeContext(1000, &callback_arg).expect("getctx failed") }; + let ctx = mssf_core::API_TABLE + .fabric_begin_get_node_context(1000, Some(&callback_arg)) + .expect("getctx failed"); token.wait(); - let result_raw = unsafe { FabricEndGetNodeContext(&ctx).expect("end failed") }; - - let result = unsafe { IFabricNodeContextResult::from_raw(result_raw) }; + let result = mssf_core::API_TABLE + .fabric_end_get_node_context::(Some(ctx).as_ref()) + .expect("cannot end get node context"); let node_ctx = unsafe { result.get_NodeContext() }; diff --git a/crates/samples/echomain-stateful2/src/test.rs b/crates/samples/echomain-stateful2/src/test.rs index 941fd14d..8893bb61 100644 --- a/crates/samples/echomain-stateful2/src/test.rs +++ b/crates/samples/echomain-stateful2/src/test.rs @@ -206,7 +206,7 @@ impl TestClient { // restart primary let desc = RestartReplicaDescription { node_name: p.node_name.clone(), - partition_id: partition_id, + partition_id, replica_or_instance_id: p.replica_id, }; let mgmt = self.fc.get_service_manager(); diff --git a/crates/tools/api/src/main.rs b/crates/tools/api/src/main.rs index f9d9f8ba..1c8ab845 100644 --- a/crates/tools/api/src/main.rs +++ b/crates/tools/api/src/main.rs @@ -44,6 +44,13 @@ fn main() -> Result<()> { // include types "--filter", "Microsoft.ServiceFabric.FabricCommon", + // exclude functions + "!Microsoft.ServiceFabric.FabricCommon.FabricDecryptText", + "!Microsoft.ServiceFabric.FabricCommon.FabricDecryptValue", + "!Microsoft.ServiceFabric.FabricCommon.FabricEncryptText", + "!Microsoft.ServiceFabric.FabricCommon.FabricEncryptText2", + "!Microsoft.ServiceFabric.FabricCommon.FabricEncryptValue", + "!Microsoft.ServiceFabric.FabricCommon.FabricGetLastErrorMessage", "--config", "implement", ])?; @@ -63,6 +70,27 @@ fn main() -> Result<()> { out_file, "--filter", "Microsoft.ServiceFabric.FabricRuntime", // include fabric types + // exclude functions + "!Microsoft.ServiceFabric.FabricRuntime.FabricBeginCreateRuntime", + "!Microsoft.ServiceFabric.FabricRuntime.FabricBeginGetActivationContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricBeginGetCodePackageActivator", + "!Microsoft.ServiceFabric.FabricRuntime.FabricBeginGetNodeContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateKeyValueStoreReplica", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateKeyValueStoreReplica2", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateKeyValueStoreReplica3", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateKeyValueStoreReplica4", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateKeyValueStoreReplica5", + "!Microsoft.ServiceFabric.FabricRuntime.FabricCreateRuntime", + "!Microsoft.ServiceFabric.FabricRuntime.FabricEndCreateRuntime", + "!Microsoft.ServiceFabric.FabricRuntime.FabricEndGetActivationContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricEndGetCodePackageActivator", + "!Microsoft.ServiceFabric.FabricRuntime.FabricEndGetNodeContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricGetActivationContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricGetCodePackageActivator", + "!Microsoft.ServiceFabric.FabricRuntime.FabricGetNodeContext", + "!Microsoft.ServiceFabric.FabricRuntime.FabricLoadEseLocalStoreSettings", + "!Microsoft.ServiceFabric.FabricRuntime.FabricLoadReplicatorSettings", + "!Microsoft.ServiceFabric.FabricRuntime.FabricLoadSecurityCredentials", "--config", "implement", ])?; @@ -83,6 +111,15 @@ fn main() -> Result<()> { out_file, "--filter", "Microsoft.ServiceFabric.FabricClient", // include fabric types + // exclude functions + "!Microsoft.ServiceFabric.FabricClient.FabricCreateClient", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateClient2", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateClient3", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateLocalClient", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateLocalClient2", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateLocalClient3", + "!Microsoft.ServiceFabric.FabricClient.FabricCreateLocalClient4", + "!Microsoft.ServiceFabric.FabricClient.FabricGetDefaultRollingUpgradeMonitoringPolicy", "--config", "implement", ])?; @@ -92,26 +129,6 @@ fn main() -> Result<()> { remove_namespace(&mut lines, "pub mod FabricClient"); write_content(out_file, lines); } - - // Generate FabricTransport - { - let out_file = "crates/libs/com/src/ServiceFabric/FabricTransport.rs"; - let log = bindgen([ - "--in", - winmd, - "--out", - out_file, - "--filter", - "Microsoft.ServiceFabric.FabricTransport", // include fabric types - "--config", - "implement", - ])?; - println!("{}", log); - let mut lines = read_file_as_lines(out_file); - remove_namespace(&mut lines, "pub mod ServiceFabric"); - remove_namespace(&mut lines, "pub mod FabricTransport"); - write_content(out_file, lines); - } Ok(()) } From 1c5e4ffb2a343bcfbf49b35a3230fba67ea6e610 Mon Sep 17 00:00:00 2001 From: Youyuan Wu Date: Mon, 9 Dec 2024 17:58:47 -0800 Subject: [PATCH 2/3] add documentation --- crates/libs/core/src/api/mod.rs | 5 +++++ crates/libs/core/src/lib.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/crates/libs/core/src/api/mod.rs b/crates/libs/core/src/api/mod.rs index 863bde8a..dcbd9d0a 100644 --- a/crates/libs/core/src/api/mod.rs +++ b/crates/libs/core/src/api/mod.rs @@ -15,9 +15,12 @@ use windows_core::{Interface, Param}; lazy_static::lazy_static! { static ref LIB_TABLE: LibTable = LibTable::create(); + /// All SF APIs entrypoints needed for mssf. + /// These APIs are lazy loaded at the first time use after app starts. pub static ref API_TABLE: ApiTable = ApiTable::create(&LIB_TABLE); } +/// Contains all the SF shared libs needs to be loaded for mssf. pub struct LibTable { fabric_runtime: libloading::Library, fabric_common: libloading::Library, @@ -43,6 +46,8 @@ fn load_fn(lib: &'static libloading::Library, name: &str) -> libloading::Symb unsafe { lib.get(name.as_bytes()) }.unwrap_or_else(|e| panic!("cannot load fn {name} :{e}")) } +/// Contains all SF APIs loaded from SF libs needed for mssf. +/// More APIs can be added here when mssf needs them. pub struct ApiTable { fabric_get_last_error_message_fn: libloading::Symbol< 'static, diff --git a/crates/libs/core/src/lib.rs b/crates/libs/core/src/lib.rs index 5375a189..9a5a2647 100644 --- a/crates/libs/core/src/lib.rs +++ b/crates/libs/core/src/lib.rs @@ -19,6 +19,7 @@ // lib that contains all common extensions for the raw fabric apis. +// SF lib entrypoint apis. pub mod api; pub use api::API_TABLE; #[cfg(feature = "tokio_async")] From 6fb88f755fc083d3757ffba8013159ccf77d3e77 Mon Sep 17 00:00:00 2001 From: Youyuan Wu Date: Thu, 12 Dec 2024 14:58:28 -0800 Subject: [PATCH 3/3] remove unused code --- crates/libs/com/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/libs/com/src/lib.rs b/crates/libs/com/src/lib.rs index 81ecce1c..baa07419 100644 --- a/crates/libs/com/src/lib.rs +++ b/crates/libs/com/src/lib.rs @@ -11,9 +11,6 @@ pub mod ServiceFabric; // expose mod directly pub use ServiceFabric::*; -// #[cfg(all(target_os = "windows", feature = "bundled_libs"))] -// pub use mssf_metadata; - // Special usage for mssf_pal. // See mssf_pal documentations for why this is used this way. use mssf_pal::*;