@breeztech/breez-sdk-spark-react-native 0.1.8-dev1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +54 -0
  3. package/android/CMakeLists.txt +79 -0
  4. package/android/build.gradle +143 -0
  5. package/android/cpp-adapter.cpp +63 -0
  6. package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeBreezSdkSparkReactNativeSpec.java +41 -0
  7. package/android/generated/android/app/build/generated/source/codegen/jni/BreezSdkSparkReactNativeSpec-generated.cpp +38 -0
  8. package/android/generated/android/app/build/generated/source/codegen/jni/BreezSdkSparkReactNativeSpec.h +31 -0
  9. package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
  10. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpecJSI-generated.cpp +32 -0
  11. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpecJSI.h +80 -0
  12. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.cpp +22 -0
  13. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.h +24 -0
  14. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.cpp +16 -0
  15. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.h +17 -0
  16. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.cpp +19 -0
  17. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.h +18 -0
  18. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.cpp +17 -0
  19. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.h +23 -0
  20. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/States.cpp +16 -0
  21. package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/States.h +19 -0
  22. package/android/gradle.properties +5 -0
  23. package/android/src/main/AndroidManifest.xml +5 -0
  24. package/android/src/main/AndroidManifestNew.xml +2 -0
  25. package/android/src/main/java/com/breeztech/breezsdkspark/BreezSdkSparkReactNativeModule.kt +43 -0
  26. package/android/src/main/java/com/breeztech/breezsdkspark/BreezSdkSparkReactNativePackage.kt +34 -0
  27. package/breeztech-breez-sdk-spark-react-native.podspec +44 -0
  28. package/cpp/breeztech-breez-sdk-spark-react-native.cpp +20 -0
  29. package/cpp/breeztech-breez-sdk-spark-react-native.h +15 -0
  30. package/cpp/generated/breez_sdk_common.cpp +3834 -0
  31. package/cpp/generated/breez_sdk_common.hpp +251 -0
  32. package/cpp/generated/breez_sdk_spark.cpp +8722 -0
  33. package/cpp/generated/breez_sdk_spark.hpp +589 -0
  34. package/cpp/generated/breez_sdk_spark_bindings.cpp +1750 -0
  35. package/cpp/generated/breez_sdk_spark_bindings.hpp +65 -0
  36. package/ios/BreezSdkSparkReactNative.h +16 -0
  37. package/ios/BreezSdkSparkReactNative.mm +66 -0
  38. package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpec-generated.mm +46 -0
  39. package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpec.h +63 -0
  40. package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpecJSI-generated.cpp +32 -0
  41. package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpecJSI.h +80 -0
  42. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.cpp +22 -0
  43. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.h +24 -0
  44. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.cpp +16 -0
  45. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.h +17 -0
  46. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.cpp +19 -0
  47. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.h +18 -0
  48. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/RCTComponentViewHelpers.h +18 -0
  49. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.cpp +17 -0
  50. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.h +23 -0
  51. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/States.cpp +16 -0
  52. package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/States.h +19 -0
  53. package/lib/commonjs/NativeBreezSdkSparkReactNative.js +10 -0
  54. package/lib/commonjs/NativeBreezSdkSparkReactNative.js.map +1 -0
  55. package/lib/commonjs/generated/breez_sdk_common-ffi.js +44 -0
  56. package/lib/commonjs/generated/breez_sdk_common-ffi.js.map +1 -0
  57. package/lib/commonjs/generated/breez_sdk_common.js +3948 -0
  58. package/lib/commonjs/generated/breez_sdk_common.js.map +1 -0
  59. package/lib/commonjs/generated/breez_sdk_spark-ffi.js +44 -0
  60. package/lib/commonjs/generated/breez_sdk_spark-ffi.js.map +1 -0
  61. package/lib/commonjs/generated/breez_sdk_spark.js +5775 -0
  62. package/lib/commonjs/generated/breez_sdk_spark.js.map +1 -0
  63. package/lib/commonjs/generated/breez_sdk_spark_bindings-ffi.js +44 -0
  64. package/lib/commonjs/generated/breez_sdk_spark_bindings-ffi.js.map +1 -0
  65. package/lib/commonjs/generated/breez_sdk_spark_bindings.js +51 -0
  66. package/lib/commonjs/generated/breez_sdk_spark_bindings.js.map +1 -0
  67. package/lib/commonjs/index.js +81 -0
  68. package/lib/commonjs/index.js.map +1 -0
  69. package/lib/commonjs/package.json +1 -0
  70. package/lib/module/NativeBreezSdkSparkReactNative.js +7 -0
  71. package/lib/module/NativeBreezSdkSparkReactNative.js.map +1 -0
  72. package/lib/module/generated/breez_sdk_common-ffi.js +43 -0
  73. package/lib/module/generated/breez_sdk_common-ffi.js.map +1 -0
  74. package/lib/module/generated/breez_sdk_common.js +3942 -0
  75. package/lib/module/generated/breez_sdk_common.js.map +1 -0
  76. package/lib/module/generated/breez_sdk_spark-ffi.js +43 -0
  77. package/lib/module/generated/breez_sdk_spark-ffi.js.map +1 -0
  78. package/lib/module/generated/breez_sdk_spark.js +5759 -0
  79. package/lib/module/generated/breez_sdk_spark.js.map +1 -0
  80. package/lib/module/generated/breez_sdk_spark_bindings-ffi.js +43 -0
  81. package/lib/module/generated/breez_sdk_spark_bindings-ffi.js.map +1 -0
  82. package/lib/module/generated/breez_sdk_spark_bindings.js +46 -0
  83. package/lib/module/generated/breez_sdk_spark_bindings.js.map +1 -0
  84. package/lib/module/index.js +44 -0
  85. package/lib/module/index.js.map +1 -0
  86. package/lib/module/package.json +1 -0
  87. package/lib/typescript/commonjs/package.json +1 -0
  88. package/lib/typescript/commonjs/src/NativeBreezSdkSparkReactNative.d.ts +8 -0
  89. package/lib/typescript/commonjs/src/NativeBreezSdkSparkReactNative.d.ts.map +1 -0
  90. package/lib/typescript/module/package.json +1 -0
  91. package/lib/typescript/module/src/NativeBreezSdkSparkReactNative.d.ts +8 -0
  92. package/lib/typescript/module/src/NativeBreezSdkSparkReactNative.d.ts.map +1 -0
  93. package/package.json +189 -0
  94. package/react-native.config.js +12 -0
  95. package/scripts/postinstall.sh +14 -0
  96. package/src/NativeBreezSdkSparkReactNative.ts +10 -0
  97. package/src/generated/breez_sdk_common-ffi.ts +394 -0
  98. package/src/generated/breez_sdk_common.ts +5502 -0
  99. package/src/generated/breez_sdk_spark-ffi.ts +751 -0
  100. package/src/generated/breez_sdk_spark.ts +9179 -0
  101. package/src/generated/breez_sdk_spark_bindings-ffi.ts +185 -0
  102. package/src/generated/breez_sdk_spark_bindings.ts +103 -0
  103. package/src/index.tsx +42 -0
@@ -0,0 +1,1750 @@
1
+ // This file was autogenerated by some hot garbage in the
2
+ // `uniffi-bindgen-react-native` crate. Trust me, you don't want to mess with
3
+ // it!
4
+ #include "breez_sdk_spark_bindings.hpp"
5
+
6
+ #include "UniffiJsiTypes.h"
7
+ #include <iostream>
8
+ #include <map>
9
+ #include <stdexcept>
10
+ #include <thread>
11
+ #include <utility>
12
+
13
+ namespace react = facebook::react;
14
+ namespace jsi = facebook::jsi;
15
+
16
+ // Calling into Rust.
17
+ extern "C" {
18
+ typedef void (*UniffiRustFutureContinuationCallback)(uint64_t data,
19
+ int8_t poll_result);
20
+ typedef void (*UniffiForeignFutureFree)(uint64_t handle);
21
+ typedef void (*UniffiCallbackInterfaceFree)(uint64_t handle);
22
+ typedef struct UniffiForeignFuture {
23
+ uint64_t handle;
24
+ UniffiForeignFutureFree free;
25
+ } UniffiForeignFuture;
26
+ typedef struct UniffiForeignFutureStructU8 {
27
+ uint8_t return_value;
28
+ RustCallStatus call_status;
29
+ } UniffiForeignFutureStructU8;
30
+ typedef void (*UniffiForeignFutureCompleteU8)(
31
+ uint64_t callback_data, UniffiForeignFutureStructU8 result);
32
+ typedef struct UniffiForeignFutureStructI8 {
33
+ int8_t return_value;
34
+ RustCallStatus call_status;
35
+ } UniffiForeignFutureStructI8;
36
+ typedef void (*UniffiForeignFutureCompleteI8)(
37
+ uint64_t callback_data, UniffiForeignFutureStructI8 result);
38
+ typedef struct UniffiForeignFutureStructU16 {
39
+ uint16_t return_value;
40
+ RustCallStatus call_status;
41
+ } UniffiForeignFutureStructU16;
42
+ typedef void (*UniffiForeignFutureCompleteU16)(
43
+ uint64_t callback_data, UniffiForeignFutureStructU16 result);
44
+ typedef struct UniffiForeignFutureStructI16 {
45
+ int16_t return_value;
46
+ RustCallStatus call_status;
47
+ } UniffiForeignFutureStructI16;
48
+ typedef void (*UniffiForeignFutureCompleteI16)(
49
+ uint64_t callback_data, UniffiForeignFutureStructI16 result);
50
+ typedef struct UniffiForeignFutureStructU32 {
51
+ uint32_t return_value;
52
+ RustCallStatus call_status;
53
+ } UniffiForeignFutureStructU32;
54
+ typedef void (*UniffiForeignFutureCompleteU32)(
55
+ uint64_t callback_data, UniffiForeignFutureStructU32 result);
56
+ typedef struct UniffiForeignFutureStructI32 {
57
+ int32_t return_value;
58
+ RustCallStatus call_status;
59
+ } UniffiForeignFutureStructI32;
60
+ typedef void (*UniffiForeignFutureCompleteI32)(
61
+ uint64_t callback_data, UniffiForeignFutureStructI32 result);
62
+ typedef struct UniffiForeignFutureStructU64 {
63
+ uint64_t return_value;
64
+ RustCallStatus call_status;
65
+ } UniffiForeignFutureStructU64;
66
+ typedef void (*UniffiForeignFutureCompleteU64)(
67
+ uint64_t callback_data, UniffiForeignFutureStructU64 result);
68
+ typedef struct UniffiForeignFutureStructI64 {
69
+ int64_t return_value;
70
+ RustCallStatus call_status;
71
+ } UniffiForeignFutureStructI64;
72
+ typedef void (*UniffiForeignFutureCompleteI64)(
73
+ uint64_t callback_data, UniffiForeignFutureStructI64 result);
74
+ typedef struct UniffiForeignFutureStructF32 {
75
+ float return_value;
76
+ RustCallStatus call_status;
77
+ } UniffiForeignFutureStructF32;
78
+ typedef void (*UniffiForeignFutureCompleteF32)(
79
+ uint64_t callback_data, UniffiForeignFutureStructF32 result);
80
+ typedef struct UniffiForeignFutureStructF64 {
81
+ double return_value;
82
+ RustCallStatus call_status;
83
+ } UniffiForeignFutureStructF64;
84
+ typedef void (*UniffiForeignFutureCompleteF64)(
85
+ uint64_t callback_data, UniffiForeignFutureStructF64 result);
86
+ typedef struct UniffiForeignFutureStructPointer {
87
+ void *return_value;
88
+ RustCallStatus call_status;
89
+ } UniffiForeignFutureStructPointer;
90
+ typedef void (*UniffiForeignFutureCompletePointer)(
91
+ uint64_t callback_data, UniffiForeignFutureStructPointer result);
92
+ typedef struct UniffiForeignFutureStructRustBuffer {
93
+ RustBuffer return_value;
94
+ RustCallStatus call_status;
95
+ } UniffiForeignFutureStructRustBuffer;
96
+ typedef void (*UniffiForeignFutureCompleteRustBuffer)(
97
+ uint64_t callback_data, UniffiForeignFutureStructRustBuffer result);
98
+ typedef struct UniffiForeignFutureStructVoid {
99
+ RustCallStatus call_status;
100
+ } UniffiForeignFutureStructVoid;
101
+ typedef void (*UniffiForeignFutureCompleteVoid)(
102
+ uint64_t callback_data, UniffiForeignFutureStructVoid result);
103
+ RustBuffer
104
+ ffi_breez_sdk_spark_bindings_rustbuffer_alloc(uint64_t size,
105
+ RustCallStatus *uniffi_out_err);
106
+ RustBuffer ffi_breez_sdk_spark_bindings_rustbuffer_from_bytes(
107
+ ForeignBytes bytes, RustCallStatus *uniffi_out_err);
108
+ void ffi_breez_sdk_spark_bindings_rustbuffer_free(
109
+ RustBuffer buf, RustCallStatus *uniffi_out_err);
110
+ RustBuffer ffi_breez_sdk_spark_bindings_rustbuffer_reserve(
111
+ RustBuffer buf, uint64_t additional, RustCallStatus *uniffi_out_err);
112
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_u8(
113
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
114
+ /*handle*/ uint64_t callback_data);
115
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_u8(
116
+ /*handle*/ uint64_t handle);
117
+ void ffi_breez_sdk_spark_bindings_rust_future_free_u8(
118
+ /*handle*/ uint64_t handle);
119
+ uint8_t ffi_breez_sdk_spark_bindings_rust_future_complete_u8(
120
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
121
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_i8(
122
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
123
+ /*handle*/ uint64_t callback_data);
124
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_i8(
125
+ /*handle*/ uint64_t handle);
126
+ void ffi_breez_sdk_spark_bindings_rust_future_free_i8(
127
+ /*handle*/ uint64_t handle);
128
+ int8_t ffi_breez_sdk_spark_bindings_rust_future_complete_i8(
129
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
130
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_u16(
131
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
132
+ /*handle*/ uint64_t callback_data);
133
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_u16(
134
+ /*handle*/ uint64_t handle);
135
+ void ffi_breez_sdk_spark_bindings_rust_future_free_u16(
136
+ /*handle*/ uint64_t handle);
137
+ uint16_t ffi_breez_sdk_spark_bindings_rust_future_complete_u16(
138
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
139
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_i16(
140
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
141
+ /*handle*/ uint64_t callback_data);
142
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_i16(
143
+ /*handle*/ uint64_t handle);
144
+ void ffi_breez_sdk_spark_bindings_rust_future_free_i16(
145
+ /*handle*/ uint64_t handle);
146
+ int16_t ffi_breez_sdk_spark_bindings_rust_future_complete_i16(
147
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
148
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_u32(
149
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
150
+ /*handle*/ uint64_t callback_data);
151
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_u32(
152
+ /*handle*/ uint64_t handle);
153
+ void ffi_breez_sdk_spark_bindings_rust_future_free_u32(
154
+ /*handle*/ uint64_t handle);
155
+ uint32_t ffi_breez_sdk_spark_bindings_rust_future_complete_u32(
156
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
157
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_i32(
158
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
159
+ /*handle*/ uint64_t callback_data);
160
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_i32(
161
+ /*handle*/ uint64_t handle);
162
+ void ffi_breez_sdk_spark_bindings_rust_future_free_i32(
163
+ /*handle*/ uint64_t handle);
164
+ int32_t ffi_breez_sdk_spark_bindings_rust_future_complete_i32(
165
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
166
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_u64(
167
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
168
+ /*handle*/ uint64_t callback_data);
169
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_u64(
170
+ /*handle*/ uint64_t handle);
171
+ void ffi_breez_sdk_spark_bindings_rust_future_free_u64(
172
+ /*handle*/ uint64_t handle);
173
+ uint64_t ffi_breez_sdk_spark_bindings_rust_future_complete_u64(
174
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
175
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_i64(
176
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
177
+ /*handle*/ uint64_t callback_data);
178
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_i64(
179
+ /*handle*/ uint64_t handle);
180
+ void ffi_breez_sdk_spark_bindings_rust_future_free_i64(
181
+ /*handle*/ uint64_t handle);
182
+ int64_t ffi_breez_sdk_spark_bindings_rust_future_complete_i64(
183
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
184
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_f32(
185
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
186
+ /*handle*/ uint64_t callback_data);
187
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_f32(
188
+ /*handle*/ uint64_t handle);
189
+ void ffi_breez_sdk_spark_bindings_rust_future_free_f32(
190
+ /*handle*/ uint64_t handle);
191
+ float ffi_breez_sdk_spark_bindings_rust_future_complete_f32(
192
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
193
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_f64(
194
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
195
+ /*handle*/ uint64_t callback_data);
196
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_f64(
197
+ /*handle*/ uint64_t handle);
198
+ void ffi_breez_sdk_spark_bindings_rust_future_free_f64(
199
+ /*handle*/ uint64_t handle);
200
+ double ffi_breez_sdk_spark_bindings_rust_future_complete_f64(
201
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
202
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_pointer(
203
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
204
+ /*handle*/ uint64_t callback_data);
205
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_pointer(
206
+ /*handle*/ uint64_t handle);
207
+ void ffi_breez_sdk_spark_bindings_rust_future_free_pointer(
208
+ /*handle*/ uint64_t handle);
209
+ void *ffi_breez_sdk_spark_bindings_rust_future_complete_pointer(
210
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
211
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_rust_buffer(
212
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
213
+ /*handle*/ uint64_t callback_data);
214
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_rust_buffer(
215
+ /*handle*/ uint64_t handle);
216
+ void ffi_breez_sdk_spark_bindings_rust_future_free_rust_buffer(
217
+ /*handle*/ uint64_t handle);
218
+ RustBuffer ffi_breez_sdk_spark_bindings_rust_future_complete_rust_buffer(
219
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
220
+ void ffi_breez_sdk_spark_bindings_rust_future_poll_void(
221
+ /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
222
+ /*handle*/ uint64_t callback_data);
223
+ void ffi_breez_sdk_spark_bindings_rust_future_cancel_void(
224
+ /*handle*/ uint64_t handle);
225
+ void ffi_breez_sdk_spark_bindings_rust_future_free_void(
226
+ /*handle*/ uint64_t handle);
227
+ void ffi_breez_sdk_spark_bindings_rust_future_complete_void(
228
+ /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
229
+ uint32_t ffi_breez_sdk_spark_bindings_uniffi_contract_version();
230
+ }
231
+
232
+ namespace uniffi::breez_sdk_spark_bindings {
233
+ template <typename T> struct Bridging;
234
+
235
+ using namespace facebook;
236
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
237
+
238
+ template <typename T> struct Bridging<ReferenceHolder<T>> {
239
+ static jsi::Value jsNew(jsi::Runtime &rt) {
240
+ auto holder = jsi::Object(rt);
241
+ return holder;
242
+ }
243
+ static T fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
244
+ const jsi::Value &value) {
245
+ auto obj = value.asObject(rt);
246
+ if (obj.hasProperty(rt, "pointee")) {
247
+ auto pointee = obj.getProperty(rt, "pointee");
248
+ return uniffi::breez_sdk_spark_bindings::Bridging<T>::fromJs(
249
+ rt, callInvoker, pointee);
250
+ }
251
+ throw jsi::JSError(rt,
252
+ "Expected ReferenceHolder to have a pointee property. "
253
+ "This is likely a bug in uniffi-bindgen-react-native");
254
+ }
255
+ };
256
+ } // namespace uniffi::breez_sdk_spark_bindings
257
+ namespace uniffi::breez_sdk_spark_bindings {
258
+ using namespace facebook;
259
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
260
+
261
+ template <> struct Bridging<RustBuffer> {
262
+ static RustBuffer rustbuffer_alloc(int32_t size) {
263
+ RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
264
+ return ffi_breez_sdk_spark_bindings_rustbuffer_alloc(size, &status);
265
+ }
266
+
267
+ static void rustbuffer_free(RustBuffer buf) {
268
+ RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
269
+ ffi_breez_sdk_spark_bindings_rustbuffer_free(buf, &status);
270
+ }
271
+
272
+ static RustBuffer rustbuffer_from_bytes(ForeignBytes bytes) {
273
+ RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
274
+ return ffi_breez_sdk_spark_bindings_rustbuffer_from_bytes(bytes, &status);
275
+ }
276
+
277
+ static RustBuffer fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
278
+ const jsi::Value &value) {
279
+ try {
280
+ auto buffer =
281
+ uniffi_jsi::Bridging<jsi::ArrayBuffer>::value_to_arraybuffer(rt,
282
+ value);
283
+ auto bytes = ForeignBytes{
284
+ .len = static_cast<int32_t>(buffer.length(rt)),
285
+ .data = buffer.data(rt),
286
+ };
287
+
288
+ // This buffer is constructed from foreign bytes. Rust scaffolding copies
289
+ // the bytes, to make the RustBuffer.
290
+ auto buf = rustbuffer_from_bytes(bytes);
291
+ // Once it leaves this function, the buffer is immediately passed back
292
+ // into Rust, where it's used to deserialize into the Rust versions of the
293
+ // arguments. At that point, the copy is destroyed.
294
+ return buf;
295
+ } catch (const std::logic_error &e) {
296
+ throw jsi::JSError(rt, e.what());
297
+ }
298
+ }
299
+
300
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
301
+ RustBuffer buf) {
302
+ // We need to make a copy of the bytes from Rust's memory space into
303
+ // Javascripts memory space. We need to do this because the two languages
304
+ // manages memory very differently: a garbage collector needs to track all
305
+ // the memory at runtime, Rust is doing it all closer to compile time.
306
+ uint8_t *bytes = new uint8_t[buf.len];
307
+ std::memcpy(bytes, buf.data, buf.len);
308
+
309
+ // Construct an ArrayBuffer with copy of the bytes from the RustBuffer.
310
+ auto payload = std::make_shared<uniffi_jsi::CMutableBuffer>(
311
+ uniffi_jsi::CMutableBuffer((uint8_t *)bytes, buf.len));
312
+ auto arrayBuffer = jsi::ArrayBuffer(rt, payload);
313
+
314
+ // Once we have a Javascript version, we no longer need the Rust version, so
315
+ // we can call into Rust to tell it it's okay to free that memory.
316
+ rustbuffer_free(buf);
317
+
318
+ // Finally, return the ArrayBuffer.
319
+ return uniffi_jsi::Bridging<jsi::ArrayBuffer>::arraybuffer_to_value(
320
+ rt, arrayBuffer);
321
+ ;
322
+ }
323
+ };
324
+
325
+ } // namespace uniffi::breez_sdk_spark_bindings
326
+
327
+ namespace uniffi::breez_sdk_spark_bindings {
328
+ using namespace facebook;
329
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
330
+
331
+ template <> struct Bridging<RustCallStatus> {
332
+ static jsi::Value jsSuccess(jsi::Runtime &rt) {
333
+ auto statusObject = jsi::Object(rt);
334
+ statusObject.setProperty(rt, "code", jsi::Value(rt, UNIFFI_CALL_STATUS_OK));
335
+ return statusObject;
336
+ }
337
+ static RustCallStatus rustSuccess(jsi::Runtime &rt) {
338
+ return {UNIFFI_CALL_STATUS_OK};
339
+ }
340
+ static void copyIntoJs(jsi::Runtime &rt,
341
+ std::shared_ptr<CallInvoker> callInvoker,
342
+ const RustCallStatus status,
343
+ const jsi::Value &jsStatus) {
344
+ auto statusObject = jsStatus.asObject(rt);
345
+ if (status.error_buf.data != nullptr) {
346
+ auto rbuf = Bridging<RustBuffer>::toJs(rt, callInvoker, status.error_buf);
347
+ statusObject.setProperty(rt, "errorBuf", rbuf);
348
+ }
349
+ if (status.code != UNIFFI_CALL_STATUS_OK) {
350
+ auto code =
351
+ uniffi_jsi::Bridging<uint8_t>::toJs(rt, callInvoker, status.code);
352
+ statusObject.setProperty(rt, "code", code);
353
+ }
354
+ }
355
+
356
+ static RustCallStatus fromJs(jsi::Runtime &rt,
357
+ std::shared_ptr<CallInvoker> invoker,
358
+ const jsi::Value &jsStatus) {
359
+ RustCallStatus status;
360
+ auto statusObject = jsStatus.asObject(rt);
361
+ if (statusObject.hasProperty(rt, "errorBuf")) {
362
+ auto rbuf = statusObject.getProperty(rt, "errorBuf");
363
+ status.error_buf = Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
364
+ }
365
+ if (statusObject.hasProperty(rt, "code")) {
366
+ auto code = statusObject.getProperty(rt, "code");
367
+ status.code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
368
+ }
369
+ return status;
370
+ }
371
+
372
+ static void copyFromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> invoker,
373
+ const jsi::Value &jsStatus, RustCallStatus *status) {
374
+ auto statusObject = jsStatus.asObject(rt);
375
+ if (statusObject.hasProperty(rt, "errorBuf")) {
376
+ auto rbuf = statusObject.getProperty(rt, "errorBuf");
377
+ status->error_buf = Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
378
+ }
379
+ if (statusObject.hasProperty(rt, "code")) {
380
+ auto code = statusObject.getProperty(rt, "code");
381
+ status->code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
382
+ }
383
+ }
384
+ };
385
+
386
+ } // namespace uniffi::breez_sdk_spark_bindings
387
+ // In other uniffi bindings, it is assumed that the foreign language holds on
388
+ // to the vtable, which the Rust just gets a pointer to.
389
+ // Here, we need to hold on to them, but also be able to clear them at just the
390
+ // right time so we can support hot-reloading.
391
+ namespace uniffi::breez_sdk_spark_bindings::registry {
392
+ template <typename T> class VTableHolder {
393
+ public:
394
+ T vtable;
395
+ VTableHolder(T v) : vtable(v) {}
396
+ };
397
+
398
+ // Mutex to bind the storage and setting of vtable together.
399
+ // We declare it here, but the lock is taken by callers of the putTable
400
+ // method who are also sending a pointer to Rust.
401
+ static std::mutex vtableMutex;
402
+
403
+ // Registry to hold all vtables so they persist even when JS objects are GC'd.
404
+ // The only reason this exists is to prevent a dangling pointer in the
405
+ // Rust machinery: i.e. we don't need to access or write to this registry
406
+ // after startup.
407
+ // Registry to hold all vtables so they persist even when JS objects are GC'd.
408
+ // Maps string identifiers to vtable holders using type erasure
409
+ static std::unordered_map<std::string, std::shared_ptr<void>> vtableRegistry;
410
+
411
+ // Add a vtable to the registry with an identifier
412
+ template <typename T>
413
+ static T *putTable(std::string_view identifier, T vtable) {
414
+ auto holder = std::make_shared<VTableHolder<T>>(vtable);
415
+ // Store the raw pointer to the vtable before type erasure
416
+ T *rawPtr = &(holder->vtable);
417
+ // Store the holder using type erasure with the string identifier
418
+ vtableRegistry[std::string(identifier)] = std::shared_ptr<void>(holder);
419
+ return rawPtr;
420
+ }
421
+
422
+ // Clear the registry.
423
+ //
424
+ // Conceptually, this is called after teardown of the module (i.e. after
425
+ // teardown of the jsi::Runtime). However, because Rust is dropping callbacks
426
+ // because the Runtime is being torn down, we must keep the registry intact
427
+ // until after the runtime goes away.
428
+ //
429
+ // Therefore, in practice we should call this when the next runtime is
430
+ // being stood up.
431
+ static void clearRegistry() {
432
+ std::lock_guard<std::mutex> lock(vtableMutex);
433
+ vtableRegistry.clear();
434
+ }
435
+ } // namespace uniffi::breez_sdk_spark_bindings::registry
436
+
437
+ // This calls into Rust.
438
+ // Implementation of callback function calling from Rust to JS
439
+ // RustFutureContinuationCallback
440
+
441
+ // Callback function:
442
+ // uniffi::breez_sdk_spark_bindings::cb::rustfuturecontinuationcallback::UniffiRustFutureContinuationCallback
443
+ //
444
+ // We have the following constraints:
445
+ // - we need to pass a function pointer to Rust.
446
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
447
+ // - function pointers can't store state, so we can't use a lamda.
448
+ //
449
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
450
+ // function calls the lambda, which itself calls the `body` which then calls
451
+ // into JS.
452
+ //
453
+ // We then give the `callback` function pointer to Rust which will call the
454
+ // lambda sometime in the future.
455
+ namespace uniffi::breez_sdk_spark_bindings::cb::rustfuturecontinuationcallback {
456
+ using namespace facebook;
457
+
458
+ // We need to store a lambda in a global so we can call it from
459
+ // a function pointer. The function pointer is passed to Rust.
460
+ static std::function<void(uint64_t, int8_t)> rsLambda = nullptr;
461
+
462
+ // This is the main body of the callback. It's called from the lambda,
463
+ // which itself is called from the callback function which is passed to Rust.
464
+ static void body(jsi::Runtime &rt,
465
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
466
+ std::shared_ptr<jsi::Value> callbackValue, uint64_t rs_data,
467
+ int8_t rs_pollResult) {
468
+
469
+ // Convert the arguments from Rust, into jsi::Values.
470
+ // We'll use the Bridging class to do this…
471
+ auto js_data = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_data);
472
+ auto js_pollResult =
473
+ uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, rs_pollResult);
474
+
475
+ // Now we are ready to call the callback.
476
+ // We are already on the JS thread, because this `body` function was
477
+ // invoked from the CallInvoker.
478
+ try {
479
+ // Getting the callback function
480
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
481
+ auto uniffiResult = cb.call(rt, js_data, js_pollResult);
482
+
483
+ } catch (const jsi::JSError &error) {
484
+ std::cout << "Error in callback UniffiRustFutureContinuationCallback: "
485
+ << error.what() << std::endl;
486
+ throw error;
487
+ }
488
+ }
489
+
490
+ static void callback(uint64_t rs_data, int8_t rs_pollResult) {
491
+ // If the runtime has shutdown, then there is no point in trying to
492
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
493
+ //
494
+ // Answer: the module destructor calls into callback `cleanup` method,
495
+ // which nulls out the rsLamda.
496
+ //
497
+ // If rsLamda is null, then there is no runtime to call into.
498
+ if (rsLambda == nullptr) {
499
+ // This only occurs when destructors are calling into Rust free/drop,
500
+ // which causes the JS callback to be dropped.
501
+ return;
502
+ }
503
+
504
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
505
+ // are all in the lambda.
506
+ rsLambda(rs_data, rs_pollResult);
507
+ }
508
+
509
+ static UniffiRustFutureContinuationCallback
510
+ makeCallbackFunction( // uniffi::breez_sdk_spark_bindings::cb::rustfuturecontinuationcallback
511
+ jsi::Runtime &rt,
512
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
513
+ const jsi::Value &value) {
514
+ if (rsLambda != nullptr) {
515
+ // `makeCallbackFunction` is called in two circumstances:
516
+ //
517
+ // 1. at startup, when initializing callback interface vtables.
518
+ // 2. when polling futures. This happens at least once per future that is
519
+ // exposed to Javascript. We know that this is always the same function,
520
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
521
+ //
522
+ // We can therefore return the callback function without making anything
523
+ // new if we've been initialized already.
524
+ return callback;
525
+ }
526
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
527
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
528
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_data,
529
+ int8_t rs_pollResult) {
530
+ // We immediately make a lambda which will do the work of transforming the
531
+ // arguments into JSI values and calling the callback.
532
+ uniffi_runtime::UniffiCallFunc jsLambda =
533
+ [callInvoker, callbackValue, rs_data,
534
+ rs_pollResult](jsi::Runtime &rt) mutable {
535
+ body(rt, callInvoker, callbackValue, rs_data, rs_pollResult);
536
+ };
537
+ // We'll then call that lambda from the callInvoker which will
538
+ // look after calling it on the correct thread.
539
+
540
+ callInvoker->invokeNonBlocking(rt, jsLambda);
541
+ };
542
+ return callback;
543
+ }
544
+
545
+ // This method is called from the destructor of NativeBreezSdkSparkBindings,
546
+ // which only happens when the jsi::Runtime is being destroyed.
547
+ static void cleanup() {
548
+ // The lambda holds a reference to the the Runtime, so when this is nulled
549
+ // out, then the pointer will no longer be left dangling.
550
+ rsLambda = nullptr;
551
+ }
552
+ } // namespace
553
+ // uniffi::breez_sdk_spark_bindings::cb::rustfuturecontinuationcallback
554
+ // Implementation of callback function calling from JS to Rust
555
+ // ForeignFutureFree, passed from Rust to JS as part of async callbacks.
556
+ namespace uniffi::breez_sdk_spark_bindings {
557
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
558
+
559
+ template <> struct Bridging<UniffiForeignFutureFree> {
560
+ static jsi::Value toJs(jsi::Runtime &rt,
561
+ std::shared_ptr<CallInvoker> callInvoker,
562
+ UniffiForeignFutureFree rsCallback) {
563
+ return jsi::Function::createFromHostFunction(
564
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureFree"), 1,
565
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
566
+ const jsi::Value *arguments,
567
+ size_t count) -> jsi::Value {
568
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
569
+ rsCallback);
570
+ });
571
+ }
572
+
573
+ static jsi::Value intoRust(jsi::Runtime &rt,
574
+ std::shared_ptr<CallInvoker> callInvoker,
575
+ const jsi::Value &thisValue,
576
+ const jsi::Value *args, size_t count,
577
+ UniffiForeignFutureFree func) {
578
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
579
+ // then call the rs_callback with those arguments.
580
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]));
581
+
582
+ return jsi::Value::undefined();
583
+ }
584
+ };
585
+ } // namespace uniffi::breez_sdk_spark_bindings
586
+ // Implementation of free callback function CallbackInterfaceFree
587
+
588
+ // Callback function:
589
+ // uniffi::breez_sdk_spark_bindings::st::foreignfuture::foreignfuture::free::UniffiCallbackInterfaceFree
590
+ //
591
+ // We have the following constraints:
592
+ // - we need to pass a function pointer to Rust.
593
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
594
+ // - function pointers can't store state, so we can't use a lamda.
595
+ //
596
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
597
+ // function calls the lambda, which itself calls the `body` which then calls
598
+ // into JS.
599
+ //
600
+ // We then give the `callback` function pointer to Rust which will call the
601
+ // lambda sometime in the future.
602
+ namespace uniffi::breez_sdk_spark_bindings::st::foreignfuture::foreignfuture::
603
+ free {
604
+ using namespace facebook;
605
+
606
+ // We need to store a lambda in a global so we can call it from
607
+ // a function pointer. The function pointer is passed to Rust.
608
+ static std::function<void(uint64_t)> rsLambda = nullptr;
609
+
610
+ // This is the main body of the callback. It's called from the lambda,
611
+ // which itself is called from the callback function which is passed to Rust.
612
+ static void body(jsi::Runtime &rt,
613
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
614
+ std::shared_ptr<jsi::Value> callbackValue,
615
+ uint64_t rs_handle) {
616
+
617
+ // Convert the arguments from Rust, into jsi::Values.
618
+ // We'll use the Bridging class to do this…
619
+ auto js_handle =
620
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
621
+
622
+ // Now we are ready to call the callback.
623
+ // We are already on the JS thread, because this `body` function was
624
+ // invoked from the CallInvoker.
625
+ try {
626
+ // Getting the callback function
627
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
628
+ auto uniffiResult = cb.call(rt, js_handle);
629
+
630
+ } catch (const jsi::JSError &error) {
631
+ std::cout << "Error in callback UniffiCallbackInterfaceFree: "
632
+ << error.what() << std::endl;
633
+ throw error;
634
+ }
635
+ }
636
+
637
+ static void callback(uint64_t rs_handle) {
638
+ // If the runtime has shutdown, then there is no point in trying to
639
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
640
+ //
641
+ // Answer: the module destructor calls into callback `cleanup` method,
642
+ // which nulls out the rsLamda.
643
+ //
644
+ // If rsLamda is null, then there is no runtime to call into.
645
+ if (rsLambda == nullptr) {
646
+ // This only occurs when destructors are calling into Rust free/drop,
647
+ // which causes the JS callback to be dropped.
648
+ return;
649
+ }
650
+
651
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
652
+ // are all in the lambda.
653
+ rsLambda(rs_handle);
654
+ }
655
+
656
+ static UniffiCallbackInterfaceFree
657
+ makeCallbackFunction( // uniffi::breez_sdk_spark_bindings::st::foreignfuture::foreignfuture::free
658
+ jsi::Runtime &rt,
659
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
660
+ const jsi::Value &value) {
661
+ if (rsLambda != nullptr) {
662
+ // `makeCallbackFunction` is called in two circumstances:
663
+ //
664
+ // 1. at startup, when initializing callback interface vtables.
665
+ // 2. when polling futures. This happens at least once per future that is
666
+ // exposed to Javascript. We know that this is always the same function,
667
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
668
+ //
669
+ // We can therefore return the callback function without making anything
670
+ // new if we've been initialized already.
671
+ return callback;
672
+ }
673
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
674
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
675
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
676
+ // We immediately make a lambda which will do the work of transforming the
677
+ // arguments into JSI values and calling the callback.
678
+ uniffi_runtime::UniffiCallFunc jsLambda =
679
+ [callInvoker, callbackValue, rs_handle](jsi::Runtime &rt) mutable {
680
+ body(rt, callInvoker, callbackValue, rs_handle);
681
+ };
682
+ // We'll then call that lambda from the callInvoker which will
683
+ // look after calling it on the correct thread.
684
+
685
+ callInvoker->invokeNonBlocking(rt, jsLambda);
686
+ };
687
+ return callback;
688
+ }
689
+
690
+ // This method is called from the destructor of NativeBreezSdkSparkBindings,
691
+ // which only happens when the jsi::Runtime is being destroyed.
692
+ static void cleanup() {
693
+ // The lambda holds a reference to the the Runtime, so when this is nulled
694
+ // out, then the pointer will no longer be left dangling.
695
+ rsLambda = nullptr;
696
+ }
697
+ } // namespace
698
+ // uniffi::breez_sdk_spark_bindings::st::foreignfuture::foreignfuture::free
699
+ namespace uniffi::breez_sdk_spark_bindings {
700
+ using namespace facebook;
701
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
702
+
703
+ template <> struct Bridging<UniffiForeignFuture> {
704
+ static UniffiForeignFuture fromJs(jsi::Runtime &rt,
705
+ std::shared_ptr<CallInvoker> callInvoker,
706
+ const jsi::Value &jsValue) {
707
+ // Check if the input is an object
708
+ if (!jsValue.isObject()) {
709
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFuture");
710
+ }
711
+
712
+ // Get the object from the jsi::Value
713
+ auto jsObject = jsValue.getObject(rt);
714
+
715
+ // Create the vtable struct
716
+ UniffiForeignFuture rsObject;
717
+
718
+ // Create the vtable from the js callbacks.
719
+ rsObject.handle = uniffi_jsi::Bridging<uint64_t>::fromJs(
720
+ rt, callInvoker, jsObject.getProperty(rt, "handle"));
721
+ rsObject.free = uniffi::breez_sdk_spark_bindings::st::foreignfuture::
722
+ foreignfuture::free::makeCallbackFunction(
723
+ rt, callInvoker, jsObject.getProperty(rt, "free"));
724
+
725
+ return rsObject;
726
+ }
727
+ };
728
+
729
+ } // namespace uniffi::breez_sdk_spark_bindings
730
+ namespace uniffi::breez_sdk_spark_bindings {
731
+ using namespace facebook;
732
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
733
+
734
+ template <> struct Bridging<UniffiForeignFutureStructU8> {
735
+ static UniffiForeignFutureStructU8
736
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
737
+ const jsi::Value &jsValue) {
738
+ // Check if the input is an object
739
+ if (!jsValue.isObject()) {
740
+ throw jsi::JSError(rt,
741
+ "Expected an object for UniffiForeignFutureStructU8");
742
+ }
743
+
744
+ // Get the object from the jsi::Value
745
+ auto jsObject = jsValue.getObject(rt);
746
+
747
+ // Create the vtable struct
748
+ UniffiForeignFutureStructU8 rsObject;
749
+
750
+ // Create the vtable from the js callbacks.
751
+ rsObject.return_value = uniffi_jsi::Bridging<uint8_t>::fromJs(
752
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
753
+ rsObject.call_status =
754
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
755
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
756
+
757
+ return rsObject;
758
+ }
759
+ };
760
+
761
+ } // namespace uniffi::breez_sdk_spark_bindings
762
+ // Implementation of callback function calling from JS to Rust
763
+ // ForeignFutureCompleteU8, passed from Rust to JS as part of async callbacks.
764
+ namespace uniffi::breez_sdk_spark_bindings {
765
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
766
+
767
+ template <> struct Bridging<UniffiForeignFutureCompleteU8> {
768
+ static jsi::Value toJs(jsi::Runtime &rt,
769
+ std::shared_ptr<CallInvoker> callInvoker,
770
+ UniffiForeignFutureCompleteU8 rsCallback) {
771
+ return jsi::Function::createFromHostFunction(
772
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU8"), 2,
773
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
774
+ const jsi::Value *arguments,
775
+ size_t count) -> jsi::Value {
776
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
777
+ rsCallback);
778
+ });
779
+ }
780
+
781
+ static jsi::Value intoRust(jsi::Runtime &rt,
782
+ std::shared_ptr<CallInvoker> callInvoker,
783
+ const jsi::Value &thisValue,
784
+ const jsi::Value *args, size_t count,
785
+ UniffiForeignFutureCompleteU8 func) {
786
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
787
+ // then call the rs_callback with those arguments.
788
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
789
+ uniffi::breez_sdk_spark_bindings::Bridging<
790
+ UniffiForeignFutureStructU8>::fromJs(rt, callInvoker, args[1]));
791
+
792
+ return jsi::Value::undefined();
793
+ }
794
+ };
795
+ } // namespace uniffi::breez_sdk_spark_bindings
796
+ namespace uniffi::breez_sdk_spark_bindings {
797
+ using namespace facebook;
798
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
799
+
800
+ template <> struct Bridging<UniffiForeignFutureStructI8> {
801
+ static UniffiForeignFutureStructI8
802
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
803
+ const jsi::Value &jsValue) {
804
+ // Check if the input is an object
805
+ if (!jsValue.isObject()) {
806
+ throw jsi::JSError(rt,
807
+ "Expected an object for UniffiForeignFutureStructI8");
808
+ }
809
+
810
+ // Get the object from the jsi::Value
811
+ auto jsObject = jsValue.getObject(rt);
812
+
813
+ // Create the vtable struct
814
+ UniffiForeignFutureStructI8 rsObject;
815
+
816
+ // Create the vtable from the js callbacks.
817
+ rsObject.return_value = uniffi_jsi::Bridging<int8_t>::fromJs(
818
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
819
+ rsObject.call_status =
820
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
821
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
822
+
823
+ return rsObject;
824
+ }
825
+ };
826
+
827
+ } // namespace uniffi::breez_sdk_spark_bindings
828
+ // Implementation of callback function calling from JS to Rust
829
+ // ForeignFutureCompleteI8, passed from Rust to JS as part of async callbacks.
830
+ namespace uniffi::breez_sdk_spark_bindings {
831
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
832
+
833
+ template <> struct Bridging<UniffiForeignFutureCompleteI8> {
834
+ static jsi::Value toJs(jsi::Runtime &rt,
835
+ std::shared_ptr<CallInvoker> callInvoker,
836
+ UniffiForeignFutureCompleteI8 rsCallback) {
837
+ return jsi::Function::createFromHostFunction(
838
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI8"), 2,
839
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
840
+ const jsi::Value *arguments,
841
+ size_t count) -> jsi::Value {
842
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
843
+ rsCallback);
844
+ });
845
+ }
846
+
847
+ static jsi::Value intoRust(jsi::Runtime &rt,
848
+ std::shared_ptr<CallInvoker> callInvoker,
849
+ const jsi::Value &thisValue,
850
+ const jsi::Value *args, size_t count,
851
+ UniffiForeignFutureCompleteI8 func) {
852
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
853
+ // then call the rs_callback with those arguments.
854
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
855
+ uniffi::breez_sdk_spark_bindings::Bridging<
856
+ UniffiForeignFutureStructI8>::fromJs(rt, callInvoker, args[1]));
857
+
858
+ return jsi::Value::undefined();
859
+ }
860
+ };
861
+ } // namespace uniffi::breez_sdk_spark_bindings
862
+ namespace uniffi::breez_sdk_spark_bindings {
863
+ using namespace facebook;
864
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
865
+
866
+ template <> struct Bridging<UniffiForeignFutureStructU16> {
867
+ static UniffiForeignFutureStructU16
868
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
869
+ const jsi::Value &jsValue) {
870
+ // Check if the input is an object
871
+ if (!jsValue.isObject()) {
872
+ throw jsi::JSError(rt,
873
+ "Expected an object for UniffiForeignFutureStructU16");
874
+ }
875
+
876
+ // Get the object from the jsi::Value
877
+ auto jsObject = jsValue.getObject(rt);
878
+
879
+ // Create the vtable struct
880
+ UniffiForeignFutureStructU16 rsObject;
881
+
882
+ // Create the vtable from the js callbacks.
883
+ rsObject.return_value = uniffi_jsi::Bridging<uint16_t>::fromJs(
884
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
885
+ rsObject.call_status =
886
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
887
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
888
+
889
+ return rsObject;
890
+ }
891
+ };
892
+
893
+ } // namespace uniffi::breez_sdk_spark_bindings
894
+ // Implementation of callback function calling from JS to Rust
895
+ // ForeignFutureCompleteU16, passed from Rust to JS as part of async
896
+ // callbacks.
897
+ namespace uniffi::breez_sdk_spark_bindings {
898
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
899
+
900
+ template <> struct Bridging<UniffiForeignFutureCompleteU16> {
901
+ static jsi::Value toJs(jsi::Runtime &rt,
902
+ std::shared_ptr<CallInvoker> callInvoker,
903
+ UniffiForeignFutureCompleteU16 rsCallback) {
904
+ return jsi::Function::createFromHostFunction(
905
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU16"), 2,
906
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
907
+ const jsi::Value *arguments,
908
+ size_t count) -> jsi::Value {
909
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
910
+ rsCallback);
911
+ });
912
+ }
913
+
914
+ static jsi::Value intoRust(jsi::Runtime &rt,
915
+ std::shared_ptr<CallInvoker> callInvoker,
916
+ const jsi::Value &thisValue,
917
+ const jsi::Value *args, size_t count,
918
+ UniffiForeignFutureCompleteU16 func) {
919
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
920
+ // then call the rs_callback with those arguments.
921
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
922
+ uniffi::breez_sdk_spark_bindings::Bridging<
923
+ UniffiForeignFutureStructU16>::fromJs(rt, callInvoker, args[1]));
924
+
925
+ return jsi::Value::undefined();
926
+ }
927
+ };
928
+ } // namespace uniffi::breez_sdk_spark_bindings
929
+ namespace uniffi::breez_sdk_spark_bindings {
930
+ using namespace facebook;
931
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
932
+
933
+ template <> struct Bridging<UniffiForeignFutureStructI16> {
934
+ static UniffiForeignFutureStructI16
935
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
936
+ const jsi::Value &jsValue) {
937
+ // Check if the input is an object
938
+ if (!jsValue.isObject()) {
939
+ throw jsi::JSError(rt,
940
+ "Expected an object for UniffiForeignFutureStructI16");
941
+ }
942
+
943
+ // Get the object from the jsi::Value
944
+ auto jsObject = jsValue.getObject(rt);
945
+
946
+ // Create the vtable struct
947
+ UniffiForeignFutureStructI16 rsObject;
948
+
949
+ // Create the vtable from the js callbacks.
950
+ rsObject.return_value = uniffi_jsi::Bridging<int16_t>::fromJs(
951
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
952
+ rsObject.call_status =
953
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
954
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
955
+
956
+ return rsObject;
957
+ }
958
+ };
959
+
960
+ } // namespace uniffi::breez_sdk_spark_bindings
961
+ // Implementation of callback function calling from JS to Rust
962
+ // ForeignFutureCompleteI16, passed from Rust to JS as part of async
963
+ // callbacks.
964
+ namespace uniffi::breez_sdk_spark_bindings {
965
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
966
+
967
+ template <> struct Bridging<UniffiForeignFutureCompleteI16> {
968
+ static jsi::Value toJs(jsi::Runtime &rt,
969
+ std::shared_ptr<CallInvoker> callInvoker,
970
+ UniffiForeignFutureCompleteI16 rsCallback) {
971
+ return jsi::Function::createFromHostFunction(
972
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI16"), 2,
973
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
974
+ const jsi::Value *arguments,
975
+ size_t count) -> jsi::Value {
976
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
977
+ rsCallback);
978
+ });
979
+ }
980
+
981
+ static jsi::Value intoRust(jsi::Runtime &rt,
982
+ std::shared_ptr<CallInvoker> callInvoker,
983
+ const jsi::Value &thisValue,
984
+ const jsi::Value *args, size_t count,
985
+ UniffiForeignFutureCompleteI16 func) {
986
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
987
+ // then call the rs_callback with those arguments.
988
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
989
+ uniffi::breez_sdk_spark_bindings::Bridging<
990
+ UniffiForeignFutureStructI16>::fromJs(rt, callInvoker, args[1]));
991
+
992
+ return jsi::Value::undefined();
993
+ }
994
+ };
995
+ } // namespace uniffi::breez_sdk_spark_bindings
996
+ namespace uniffi::breez_sdk_spark_bindings {
997
+ using namespace facebook;
998
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
999
+
1000
+ template <> struct Bridging<UniffiForeignFutureStructU32> {
1001
+ static UniffiForeignFutureStructU32
1002
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1003
+ const jsi::Value &jsValue) {
1004
+ // Check if the input is an object
1005
+ if (!jsValue.isObject()) {
1006
+ throw jsi::JSError(rt,
1007
+ "Expected an object for UniffiForeignFutureStructU32");
1008
+ }
1009
+
1010
+ // Get the object from the jsi::Value
1011
+ auto jsObject = jsValue.getObject(rt);
1012
+
1013
+ // Create the vtable struct
1014
+ UniffiForeignFutureStructU32 rsObject;
1015
+
1016
+ // Create the vtable from the js callbacks.
1017
+ rsObject.return_value = uniffi_jsi::Bridging<uint32_t>::fromJs(
1018
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1019
+ rsObject.call_status =
1020
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1021
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1022
+
1023
+ return rsObject;
1024
+ }
1025
+ };
1026
+
1027
+ } // namespace uniffi::breez_sdk_spark_bindings
1028
+ // Implementation of callback function calling from JS to Rust
1029
+ // ForeignFutureCompleteU32, passed from Rust to JS as part of async
1030
+ // callbacks.
1031
+ namespace uniffi::breez_sdk_spark_bindings {
1032
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1033
+
1034
+ template <> struct Bridging<UniffiForeignFutureCompleteU32> {
1035
+ static jsi::Value toJs(jsi::Runtime &rt,
1036
+ std::shared_ptr<CallInvoker> callInvoker,
1037
+ UniffiForeignFutureCompleteU32 rsCallback) {
1038
+ return jsi::Function::createFromHostFunction(
1039
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU32"), 2,
1040
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1041
+ const jsi::Value *arguments,
1042
+ size_t count) -> jsi::Value {
1043
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1044
+ rsCallback);
1045
+ });
1046
+ }
1047
+
1048
+ static jsi::Value intoRust(jsi::Runtime &rt,
1049
+ std::shared_ptr<CallInvoker> callInvoker,
1050
+ const jsi::Value &thisValue,
1051
+ const jsi::Value *args, size_t count,
1052
+ UniffiForeignFutureCompleteU32 func) {
1053
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1054
+ // then call the rs_callback with those arguments.
1055
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1056
+ uniffi::breez_sdk_spark_bindings::Bridging<
1057
+ UniffiForeignFutureStructU32>::fromJs(rt, callInvoker, args[1]));
1058
+
1059
+ return jsi::Value::undefined();
1060
+ }
1061
+ };
1062
+ } // namespace uniffi::breez_sdk_spark_bindings
1063
+ namespace uniffi::breez_sdk_spark_bindings {
1064
+ using namespace facebook;
1065
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1066
+
1067
+ template <> struct Bridging<UniffiForeignFutureStructI32> {
1068
+ static UniffiForeignFutureStructI32
1069
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1070
+ const jsi::Value &jsValue) {
1071
+ // Check if the input is an object
1072
+ if (!jsValue.isObject()) {
1073
+ throw jsi::JSError(rt,
1074
+ "Expected an object for UniffiForeignFutureStructI32");
1075
+ }
1076
+
1077
+ // Get the object from the jsi::Value
1078
+ auto jsObject = jsValue.getObject(rt);
1079
+
1080
+ // Create the vtable struct
1081
+ UniffiForeignFutureStructI32 rsObject;
1082
+
1083
+ // Create the vtable from the js callbacks.
1084
+ rsObject.return_value = uniffi_jsi::Bridging<int32_t>::fromJs(
1085
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1086
+ rsObject.call_status =
1087
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1088
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1089
+
1090
+ return rsObject;
1091
+ }
1092
+ };
1093
+
1094
+ } // namespace uniffi::breez_sdk_spark_bindings
1095
+ // Implementation of callback function calling from JS to Rust
1096
+ // ForeignFutureCompleteI32, passed from Rust to JS as part of async
1097
+ // callbacks.
1098
+ namespace uniffi::breez_sdk_spark_bindings {
1099
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1100
+
1101
+ template <> struct Bridging<UniffiForeignFutureCompleteI32> {
1102
+ static jsi::Value toJs(jsi::Runtime &rt,
1103
+ std::shared_ptr<CallInvoker> callInvoker,
1104
+ UniffiForeignFutureCompleteI32 rsCallback) {
1105
+ return jsi::Function::createFromHostFunction(
1106
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI32"), 2,
1107
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1108
+ const jsi::Value *arguments,
1109
+ size_t count) -> jsi::Value {
1110
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1111
+ rsCallback);
1112
+ });
1113
+ }
1114
+
1115
+ static jsi::Value intoRust(jsi::Runtime &rt,
1116
+ std::shared_ptr<CallInvoker> callInvoker,
1117
+ const jsi::Value &thisValue,
1118
+ const jsi::Value *args, size_t count,
1119
+ UniffiForeignFutureCompleteI32 func) {
1120
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1121
+ // then call the rs_callback with those arguments.
1122
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1123
+ uniffi::breez_sdk_spark_bindings::Bridging<
1124
+ UniffiForeignFutureStructI32>::fromJs(rt, callInvoker, args[1]));
1125
+
1126
+ return jsi::Value::undefined();
1127
+ }
1128
+ };
1129
+ } // namespace uniffi::breez_sdk_spark_bindings
1130
+ namespace uniffi::breez_sdk_spark_bindings {
1131
+ using namespace facebook;
1132
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1133
+
1134
+ template <> struct Bridging<UniffiForeignFutureStructU64> {
1135
+ static UniffiForeignFutureStructU64
1136
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1137
+ const jsi::Value &jsValue) {
1138
+ // Check if the input is an object
1139
+ if (!jsValue.isObject()) {
1140
+ throw jsi::JSError(rt,
1141
+ "Expected an object for UniffiForeignFutureStructU64");
1142
+ }
1143
+
1144
+ // Get the object from the jsi::Value
1145
+ auto jsObject = jsValue.getObject(rt);
1146
+
1147
+ // Create the vtable struct
1148
+ UniffiForeignFutureStructU64 rsObject;
1149
+
1150
+ // Create the vtable from the js callbacks.
1151
+ rsObject.return_value = uniffi_jsi::Bridging<uint64_t>::fromJs(
1152
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1153
+ rsObject.call_status =
1154
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1155
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1156
+
1157
+ return rsObject;
1158
+ }
1159
+ };
1160
+
1161
+ } // namespace uniffi::breez_sdk_spark_bindings
1162
+ // Implementation of callback function calling from JS to Rust
1163
+ // ForeignFutureCompleteU64, passed from Rust to JS as part of async
1164
+ // callbacks.
1165
+ namespace uniffi::breez_sdk_spark_bindings {
1166
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1167
+
1168
+ template <> struct Bridging<UniffiForeignFutureCompleteU64> {
1169
+ static jsi::Value toJs(jsi::Runtime &rt,
1170
+ std::shared_ptr<CallInvoker> callInvoker,
1171
+ UniffiForeignFutureCompleteU64 rsCallback) {
1172
+ return jsi::Function::createFromHostFunction(
1173
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU64"), 2,
1174
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1175
+ const jsi::Value *arguments,
1176
+ size_t count) -> jsi::Value {
1177
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1178
+ rsCallback);
1179
+ });
1180
+ }
1181
+
1182
+ static jsi::Value intoRust(jsi::Runtime &rt,
1183
+ std::shared_ptr<CallInvoker> callInvoker,
1184
+ const jsi::Value &thisValue,
1185
+ const jsi::Value *args, size_t count,
1186
+ UniffiForeignFutureCompleteU64 func) {
1187
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1188
+ // then call the rs_callback with those arguments.
1189
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1190
+ uniffi::breez_sdk_spark_bindings::Bridging<
1191
+ UniffiForeignFutureStructU64>::fromJs(rt, callInvoker, args[1]));
1192
+
1193
+ return jsi::Value::undefined();
1194
+ }
1195
+ };
1196
+ } // namespace uniffi::breez_sdk_spark_bindings
1197
+ namespace uniffi::breez_sdk_spark_bindings {
1198
+ using namespace facebook;
1199
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1200
+
1201
+ template <> struct Bridging<UniffiForeignFutureStructI64> {
1202
+ static UniffiForeignFutureStructI64
1203
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1204
+ const jsi::Value &jsValue) {
1205
+ // Check if the input is an object
1206
+ if (!jsValue.isObject()) {
1207
+ throw jsi::JSError(rt,
1208
+ "Expected an object for UniffiForeignFutureStructI64");
1209
+ }
1210
+
1211
+ // Get the object from the jsi::Value
1212
+ auto jsObject = jsValue.getObject(rt);
1213
+
1214
+ // Create the vtable struct
1215
+ UniffiForeignFutureStructI64 rsObject;
1216
+
1217
+ // Create the vtable from the js callbacks.
1218
+ rsObject.return_value = uniffi_jsi::Bridging<int64_t>::fromJs(
1219
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1220
+ rsObject.call_status =
1221
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1222
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1223
+
1224
+ return rsObject;
1225
+ }
1226
+ };
1227
+
1228
+ } // namespace uniffi::breez_sdk_spark_bindings
1229
+ // Implementation of callback function calling from JS to Rust
1230
+ // ForeignFutureCompleteI64, passed from Rust to JS as part of async
1231
+ // callbacks.
1232
+ namespace uniffi::breez_sdk_spark_bindings {
1233
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1234
+
1235
+ template <> struct Bridging<UniffiForeignFutureCompleteI64> {
1236
+ static jsi::Value toJs(jsi::Runtime &rt,
1237
+ std::shared_ptr<CallInvoker> callInvoker,
1238
+ UniffiForeignFutureCompleteI64 rsCallback) {
1239
+ return jsi::Function::createFromHostFunction(
1240
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI64"), 2,
1241
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1242
+ const jsi::Value *arguments,
1243
+ size_t count) -> jsi::Value {
1244
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1245
+ rsCallback);
1246
+ });
1247
+ }
1248
+
1249
+ static jsi::Value intoRust(jsi::Runtime &rt,
1250
+ std::shared_ptr<CallInvoker> callInvoker,
1251
+ const jsi::Value &thisValue,
1252
+ const jsi::Value *args, size_t count,
1253
+ UniffiForeignFutureCompleteI64 func) {
1254
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1255
+ // then call the rs_callback with those arguments.
1256
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1257
+ uniffi::breez_sdk_spark_bindings::Bridging<
1258
+ UniffiForeignFutureStructI64>::fromJs(rt, callInvoker, args[1]));
1259
+
1260
+ return jsi::Value::undefined();
1261
+ }
1262
+ };
1263
+ } // namespace uniffi::breez_sdk_spark_bindings
1264
+ namespace uniffi::breez_sdk_spark_bindings {
1265
+ using namespace facebook;
1266
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1267
+
1268
+ template <> struct Bridging<UniffiForeignFutureStructF32> {
1269
+ static UniffiForeignFutureStructF32
1270
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1271
+ const jsi::Value &jsValue) {
1272
+ // Check if the input is an object
1273
+ if (!jsValue.isObject()) {
1274
+ throw jsi::JSError(rt,
1275
+ "Expected an object for UniffiForeignFutureStructF32");
1276
+ }
1277
+
1278
+ // Get the object from the jsi::Value
1279
+ auto jsObject = jsValue.getObject(rt);
1280
+
1281
+ // Create the vtable struct
1282
+ UniffiForeignFutureStructF32 rsObject;
1283
+
1284
+ // Create the vtable from the js callbacks.
1285
+ rsObject.return_value = uniffi_jsi::Bridging<float>::fromJs(
1286
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1287
+ rsObject.call_status =
1288
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1289
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1290
+
1291
+ return rsObject;
1292
+ }
1293
+ };
1294
+
1295
+ } // namespace uniffi::breez_sdk_spark_bindings
1296
+ // Implementation of callback function calling from JS to Rust
1297
+ // ForeignFutureCompleteF32, passed from Rust to JS as part of async
1298
+ // callbacks.
1299
+ namespace uniffi::breez_sdk_spark_bindings {
1300
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1301
+
1302
+ template <> struct Bridging<UniffiForeignFutureCompleteF32> {
1303
+ static jsi::Value toJs(jsi::Runtime &rt,
1304
+ std::shared_ptr<CallInvoker> callInvoker,
1305
+ UniffiForeignFutureCompleteF32 rsCallback) {
1306
+ return jsi::Function::createFromHostFunction(
1307
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF32"), 2,
1308
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1309
+ const jsi::Value *arguments,
1310
+ size_t count) -> jsi::Value {
1311
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1312
+ rsCallback);
1313
+ });
1314
+ }
1315
+
1316
+ static jsi::Value intoRust(jsi::Runtime &rt,
1317
+ std::shared_ptr<CallInvoker> callInvoker,
1318
+ const jsi::Value &thisValue,
1319
+ const jsi::Value *args, size_t count,
1320
+ UniffiForeignFutureCompleteF32 func) {
1321
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1322
+ // then call the rs_callback with those arguments.
1323
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1324
+ uniffi::breez_sdk_spark_bindings::Bridging<
1325
+ UniffiForeignFutureStructF32>::fromJs(rt, callInvoker, args[1]));
1326
+
1327
+ return jsi::Value::undefined();
1328
+ }
1329
+ };
1330
+ } // namespace uniffi::breez_sdk_spark_bindings
1331
+ namespace uniffi::breez_sdk_spark_bindings {
1332
+ using namespace facebook;
1333
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1334
+
1335
+ template <> struct Bridging<UniffiForeignFutureStructF64> {
1336
+ static UniffiForeignFutureStructF64
1337
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1338
+ const jsi::Value &jsValue) {
1339
+ // Check if the input is an object
1340
+ if (!jsValue.isObject()) {
1341
+ throw jsi::JSError(rt,
1342
+ "Expected an object for UniffiForeignFutureStructF64");
1343
+ }
1344
+
1345
+ // Get the object from the jsi::Value
1346
+ auto jsObject = jsValue.getObject(rt);
1347
+
1348
+ // Create the vtable struct
1349
+ UniffiForeignFutureStructF64 rsObject;
1350
+
1351
+ // Create the vtable from the js callbacks.
1352
+ rsObject.return_value = uniffi_jsi::Bridging<double>::fromJs(
1353
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1354
+ rsObject.call_status =
1355
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1356
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1357
+
1358
+ return rsObject;
1359
+ }
1360
+ };
1361
+
1362
+ } // namespace uniffi::breez_sdk_spark_bindings
1363
+ // Implementation of callback function calling from JS to Rust
1364
+ // ForeignFutureCompleteF64, passed from Rust to JS as part of async
1365
+ // callbacks.
1366
+ namespace uniffi::breez_sdk_spark_bindings {
1367
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1368
+
1369
+ template <> struct Bridging<UniffiForeignFutureCompleteF64> {
1370
+ static jsi::Value toJs(jsi::Runtime &rt,
1371
+ std::shared_ptr<CallInvoker> callInvoker,
1372
+ UniffiForeignFutureCompleteF64 rsCallback) {
1373
+ return jsi::Function::createFromHostFunction(
1374
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF64"), 2,
1375
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1376
+ const jsi::Value *arguments,
1377
+ size_t count) -> jsi::Value {
1378
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1379
+ rsCallback);
1380
+ });
1381
+ }
1382
+
1383
+ static jsi::Value intoRust(jsi::Runtime &rt,
1384
+ std::shared_ptr<CallInvoker> callInvoker,
1385
+ const jsi::Value &thisValue,
1386
+ const jsi::Value *args, size_t count,
1387
+ UniffiForeignFutureCompleteF64 func) {
1388
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1389
+ // then call the rs_callback with those arguments.
1390
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1391
+ uniffi::breez_sdk_spark_bindings::Bridging<
1392
+ UniffiForeignFutureStructF64>::fromJs(rt, callInvoker, args[1]));
1393
+
1394
+ return jsi::Value::undefined();
1395
+ }
1396
+ };
1397
+ } // namespace uniffi::breez_sdk_spark_bindings
1398
+ namespace uniffi::breez_sdk_spark_bindings {
1399
+ using namespace facebook;
1400
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1401
+
1402
+ template <> struct Bridging<UniffiForeignFutureStructPointer> {
1403
+ static UniffiForeignFutureStructPointer
1404
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1405
+ const jsi::Value &jsValue) {
1406
+ // Check if the input is an object
1407
+ if (!jsValue.isObject()) {
1408
+ throw jsi::JSError(
1409
+ rt, "Expected an object for UniffiForeignFutureStructPointer");
1410
+ }
1411
+
1412
+ // Get the object from the jsi::Value
1413
+ auto jsObject = jsValue.getObject(rt);
1414
+
1415
+ // Create the vtable struct
1416
+ UniffiForeignFutureStructPointer rsObject;
1417
+
1418
+ // Create the vtable from the js callbacks.
1419
+ rsObject.return_value = uniffi_jsi::Bridging<void *>::fromJs(
1420
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1421
+ rsObject.call_status =
1422
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1423
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1424
+
1425
+ return rsObject;
1426
+ }
1427
+ };
1428
+
1429
+ } // namespace uniffi::breez_sdk_spark_bindings
1430
+ // Implementation of callback function calling from JS to Rust
1431
+ // ForeignFutureCompletePointer, passed from Rust to JS as part of async
1432
+ // callbacks.
1433
+ namespace uniffi::breez_sdk_spark_bindings {
1434
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1435
+
1436
+ template <> struct Bridging<UniffiForeignFutureCompletePointer> {
1437
+ static jsi::Value toJs(jsi::Runtime &rt,
1438
+ std::shared_ptr<CallInvoker> callInvoker,
1439
+ UniffiForeignFutureCompletePointer rsCallback) {
1440
+ return jsi::Function::createFromHostFunction(
1441
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompletePointer"), 2,
1442
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1443
+ const jsi::Value *arguments,
1444
+ size_t count) -> jsi::Value {
1445
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1446
+ rsCallback);
1447
+ });
1448
+ }
1449
+
1450
+ static jsi::Value intoRust(jsi::Runtime &rt,
1451
+ std::shared_ptr<CallInvoker> callInvoker,
1452
+ const jsi::Value &thisValue,
1453
+ const jsi::Value *args, size_t count,
1454
+ UniffiForeignFutureCompletePointer func) {
1455
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1456
+ // then call the rs_callback with those arguments.
1457
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1458
+ uniffi::breez_sdk_spark_bindings::Bridging<
1459
+ UniffiForeignFutureStructPointer>::fromJs(rt, callInvoker,
1460
+ args[1]));
1461
+
1462
+ return jsi::Value::undefined();
1463
+ }
1464
+ };
1465
+ } // namespace uniffi::breez_sdk_spark_bindings
1466
+ namespace uniffi::breez_sdk_spark_bindings {
1467
+ using namespace facebook;
1468
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1469
+
1470
+ template <> struct Bridging<UniffiForeignFutureStructRustBuffer> {
1471
+ static UniffiForeignFutureStructRustBuffer
1472
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1473
+ const jsi::Value &jsValue) {
1474
+ // Check if the input is an object
1475
+ if (!jsValue.isObject()) {
1476
+ throw jsi::JSError(
1477
+ rt, "Expected an object for UniffiForeignFutureStructRustBuffer");
1478
+ }
1479
+
1480
+ // Get the object from the jsi::Value
1481
+ auto jsObject = jsValue.getObject(rt);
1482
+
1483
+ // Create the vtable struct
1484
+ UniffiForeignFutureStructRustBuffer rsObject;
1485
+
1486
+ // Create the vtable from the js callbacks.
1487
+ rsObject.return_value =
1488
+ uniffi::breez_sdk_spark_bindings::Bridging<RustBuffer>::fromJs(
1489
+ rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
1490
+ rsObject.call_status =
1491
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1492
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1493
+
1494
+ return rsObject;
1495
+ }
1496
+ };
1497
+
1498
+ } // namespace uniffi::breez_sdk_spark_bindings
1499
+ // Implementation of callback function calling from JS to Rust
1500
+ // ForeignFutureCompleteRustBuffer, passed from Rust to JS as part of async
1501
+ // callbacks.
1502
+ namespace uniffi::breez_sdk_spark_bindings {
1503
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1504
+
1505
+ template <> struct Bridging<UniffiForeignFutureCompleteRustBuffer> {
1506
+ static jsi::Value toJs(jsi::Runtime &rt,
1507
+ std::shared_ptr<CallInvoker> callInvoker,
1508
+ UniffiForeignFutureCompleteRustBuffer rsCallback) {
1509
+ return jsi::Function::createFromHostFunction(
1510
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteRustBuffer"),
1511
+ 2,
1512
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1513
+ const jsi::Value *arguments,
1514
+ size_t count) -> jsi::Value {
1515
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1516
+ rsCallback);
1517
+ });
1518
+ }
1519
+
1520
+ static jsi::Value intoRust(jsi::Runtime &rt,
1521
+ std::shared_ptr<CallInvoker> callInvoker,
1522
+ const jsi::Value &thisValue,
1523
+ const jsi::Value *args, size_t count,
1524
+ UniffiForeignFutureCompleteRustBuffer func) {
1525
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1526
+ // then call the rs_callback with those arguments.
1527
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1528
+ uniffi::breez_sdk_spark_bindings::Bridging<
1529
+ UniffiForeignFutureStructRustBuffer>::fromJs(rt, callInvoker,
1530
+ args[1]));
1531
+
1532
+ return jsi::Value::undefined();
1533
+ }
1534
+ };
1535
+ } // namespace uniffi::breez_sdk_spark_bindings
1536
+ namespace uniffi::breez_sdk_spark_bindings {
1537
+ using namespace facebook;
1538
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1539
+
1540
+ template <> struct Bridging<UniffiForeignFutureStructVoid> {
1541
+ static UniffiForeignFutureStructVoid
1542
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1543
+ const jsi::Value &jsValue) {
1544
+ // Check if the input is an object
1545
+ if (!jsValue.isObject()) {
1546
+ throw jsi::JSError(
1547
+ rt, "Expected an object for UniffiForeignFutureStructVoid");
1548
+ }
1549
+
1550
+ // Get the object from the jsi::Value
1551
+ auto jsObject = jsValue.getObject(rt);
1552
+
1553
+ // Create the vtable struct
1554
+ UniffiForeignFutureStructVoid rsObject;
1555
+
1556
+ // Create the vtable from the js callbacks.
1557
+ rsObject.call_status =
1558
+ uniffi::breez_sdk_spark_bindings::Bridging<RustCallStatus>::fromJs(
1559
+ rt, callInvoker, jsObject.getProperty(rt, "callStatus"));
1560
+
1561
+ return rsObject;
1562
+ }
1563
+ };
1564
+
1565
+ } // namespace uniffi::breez_sdk_spark_bindings
1566
+ // Implementation of callback function calling from JS to Rust
1567
+ // ForeignFutureCompleteVoid, passed from Rust to JS as part of async
1568
+ // callbacks.
1569
+ namespace uniffi::breez_sdk_spark_bindings {
1570
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1571
+
1572
+ template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
1573
+ static jsi::Value toJs(jsi::Runtime &rt,
1574
+ std::shared_ptr<CallInvoker> callInvoker,
1575
+ UniffiForeignFutureCompleteVoid rsCallback) {
1576
+ return jsi::Function::createFromHostFunction(
1577
+ rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"), 2,
1578
+ [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
1579
+ const jsi::Value *arguments,
1580
+ size_t count) -> jsi::Value {
1581
+ return intoRust(rt, callInvoker, thisValue, arguments, count,
1582
+ rsCallback);
1583
+ });
1584
+ }
1585
+
1586
+ static jsi::Value intoRust(jsi::Runtime &rt,
1587
+ std::shared_ptr<CallInvoker> callInvoker,
1588
+ const jsi::Value &thisValue,
1589
+ const jsi::Value *args, size_t count,
1590
+ UniffiForeignFutureCompleteVoid func) {
1591
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1592
+ // then call the rs_callback with those arguments.
1593
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
1594
+ uniffi::breez_sdk_spark_bindings::Bridging<
1595
+ UniffiForeignFutureStructVoid>::fromJs(rt, callInvoker, args[1]));
1596
+
1597
+ return jsi::Value::undefined();
1598
+ }
1599
+ };
1600
+ } // namespace uniffi::breez_sdk_spark_bindings
1601
+
1602
+ namespace uniffi::breez_sdk_spark_bindings {
1603
+ using namespace facebook;
1604
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1605
+
1606
+ template <> struct Bridging<UniffiRustFutureContinuationCallback> {
1607
+ static UniffiRustFutureContinuationCallback
1608
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
1609
+ const jsi::Value &value) {
1610
+ try {
1611
+ return uniffi::breez_sdk_spark_bindings::cb::
1612
+ rustfuturecontinuationcallback::makeCallbackFunction(rt, callInvoker,
1613
+ value);
1614
+ } catch (const std::logic_error &e) {
1615
+ throw jsi::JSError(rt, e.what());
1616
+ }
1617
+ }
1618
+ };
1619
+
1620
+ } // namespace uniffi::breez_sdk_spark_bindings
1621
+
1622
+ NativeBreezSdkSparkBindings::NativeBreezSdkSparkBindings(
1623
+ jsi::Runtime &rt,
1624
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> invoker)
1625
+ : callInvoker(invoker), props() {
1626
+ // Map from Javascript names to the cpp names
1627
+ props["ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"] =
1628
+ jsi::Function::createFromHostFunction(
1629
+ rt,
1630
+ jsi::PropNameID::forAscii(
1631
+ rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"),
1632
+ 1,
1633
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
1634
+ const jsi::Value *args, size_t count) -> jsi::Value {
1635
+ return this->cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(
1636
+ rt, thisVal, args, count);
1637
+ });
1638
+ props["ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"] =
1639
+ jsi::Function::createFromHostFunction(
1640
+ rt,
1641
+ jsi::PropNameID::forAscii(
1642
+ rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"),
1643
+ 1,
1644
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
1645
+ const jsi::Value *args, size_t count) -> jsi::Value {
1646
+ return this->cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
1647
+ rt, thisVal, args, count);
1648
+ });
1649
+ props["ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"] =
1650
+ jsi::Function::createFromHostFunction(
1651
+ rt,
1652
+ jsi::PropNameID::forAscii(
1653
+ rt, "ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"),
1654
+ 1,
1655
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
1656
+ const jsi::Value *args, size_t count) -> jsi::Value {
1657
+ return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
1658
+ rt, thisVal, args, count);
1659
+ });
1660
+ props["ubrn_ffi_breez_sdk_spark_bindings_uniffi_contract_version"] =
1661
+ jsi::Function::createFromHostFunction(
1662
+ rt,
1663
+ jsi::PropNameID::forAscii(
1664
+ rt, "ubrn_ffi_breez_sdk_spark_bindings_uniffi_contract_version"),
1665
+ 0,
1666
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
1667
+ const jsi::Value *args, size_t count) -> jsi::Value {
1668
+ return this
1669
+ ->cpp_ffi_breez_sdk_spark_bindings_uniffi_contract_version(
1670
+ rt, thisVal, args, count);
1671
+ });
1672
+ }
1673
+
1674
+ void NativeBreezSdkSparkBindings::registerModule(
1675
+ jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker) {
1676
+ auto invoker =
1677
+ std::make_shared<uniffi_runtime::UniffiCallInvoker>(callInvoker);
1678
+ auto tm = std::make_shared<NativeBreezSdkSparkBindings>(rt, invoker);
1679
+ auto obj = rt.global().createFromHostObject(rt, tm);
1680
+ rt.global().setProperty(rt, "NativeBreezSdkSparkBindings", obj);
1681
+ }
1682
+
1683
+ void NativeBreezSdkSparkBindings::unregisterModule(jsi::Runtime &rt) {
1684
+ uniffi::breez_sdk_spark_bindings::registry::clearRegistry();
1685
+ }
1686
+
1687
+ jsi::Value NativeBreezSdkSparkBindings::get(jsi::Runtime &rt,
1688
+ const jsi::PropNameID &name) {
1689
+ try {
1690
+ return jsi::Value(rt, props.at(name.utf8(rt)));
1691
+ } catch (std::out_of_range &e) {
1692
+ return jsi::Value::undefined();
1693
+ }
1694
+ }
1695
+
1696
+ std::vector<jsi::PropNameID>
1697
+ NativeBreezSdkSparkBindings::getPropertyNames(jsi::Runtime &rt) {
1698
+ std::vector<jsi::PropNameID> rval;
1699
+ for (auto &[key, value] : props) {
1700
+ rval.push_back(jsi::PropNameID::forUtf8(rt, key));
1701
+ }
1702
+ return rval;
1703
+ }
1704
+
1705
+ void NativeBreezSdkSparkBindings::set(jsi::Runtime &rt,
1706
+ const jsi::PropNameID &name,
1707
+ const jsi::Value &value) {
1708
+ props.insert_or_assign(name.utf8(rt), &value);
1709
+ }
1710
+
1711
+ NativeBreezSdkSparkBindings::~NativeBreezSdkSparkBindings() {
1712
+ // Cleanup for callback function RustFutureContinuationCallback
1713
+ uniffi::breez_sdk_spark_bindings::cb::rustfuturecontinuationcallback::
1714
+ cleanup();
1715
+ // Cleanup for "free" callback function CallbackInterfaceFree
1716
+ uniffi::breez_sdk_spark_bindings::st::foreignfuture::foreignfuture::free::
1717
+ cleanup();
1718
+ }
1719
+
1720
+ // Utility functions for serialization/deserialization of strings.
1721
+ jsi::Value NativeBreezSdkSparkBindings::
1722
+ cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(
1723
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
1724
+ size_t count) {
1725
+ return uniffi_jsi::Bridging<std::string>::string_to_bytelength(rt, args[0]);
1726
+ }
1727
+
1728
+ jsi::Value NativeBreezSdkSparkBindings::
1729
+ cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
1730
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
1731
+ size_t count) {
1732
+ return uniffi_jsi::Bridging<std::string>::string_to_arraybuffer(rt, args[0]);
1733
+ }
1734
+
1735
+ jsi::Value NativeBreezSdkSparkBindings::
1736
+ cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
1737
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
1738
+ size_t count) {
1739
+ return uniffi_jsi::Bridging<std::string>::arraybuffer_to_string(rt, args[0]);
1740
+ }
1741
+
1742
+ // Methods calling directly into the uniffi generated C API of the Rust crate.
1743
+ jsi::Value NativeBreezSdkSparkBindings::
1744
+ cpp_ffi_breez_sdk_spark_bindings_uniffi_contract_version(
1745
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
1746
+ size_t count) {
1747
+ auto value = ffi_breez_sdk_spark_bindings_uniffi_contract_version();
1748
+
1749
+ return uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, value);
1750
+ }