@synonymdev/react-native-pubky 0.10.6 → 0.11.0
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.
- package/android/build.gradle +5 -3
- package/android/src/main/java/com/pubky/PubkyModule.kt +25 -25
- package/android/src/main/java/uniffi/pubkycore/pubkycore.kt +1402 -826
- package/android/src/main/jniLibs/arm64-v8a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkycore.so +0 -0
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/module.modulemap +3 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +688 -134
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/libpubkycore.a +0 -0
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/module.modulemap +3 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +688 -134
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a +0 -0
- package/ios/Pubky.swift +20 -20
- package/ios/pubkycore.swift +438 -369
- package/lib/commonjs/index.js +18 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +17 -17
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +5 -4
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +5 -4
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/index.tsx +25 -18
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
@file:Suppress("NAME_SHADOWING")
|
|
5
5
|
|
|
6
|
-
package uniffi.pubkycore
|
|
6
|
+
package uniffi.pubkycore
|
|
7
7
|
|
|
8
8
|
// Common helper code.
|
|
9
9
|
//
|
|
@@ -28,44 +28,54 @@ import java.nio.ByteBuffer
|
|
|
28
28
|
import java.nio.ByteOrder
|
|
29
29
|
import java.nio.CharBuffer
|
|
30
30
|
import java.nio.charset.CodingErrorAction
|
|
31
|
+
import java.util.concurrent.atomic.AtomicLong
|
|
31
32
|
import java.util.concurrent.ConcurrentHashMap
|
|
32
33
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
33
|
-
import java.util.concurrent.atomic.AtomicLong
|
|
34
|
-
import java.util.concurrent.locks.ReentrantLock
|
|
35
|
-
import kotlin.concurrent.withLock
|
|
36
34
|
|
|
37
35
|
// This is a helper for safely working with byte buffers returned from the Rust code.
|
|
38
36
|
// A rust-owned buffer is represented by its capacity, its current length, and a
|
|
39
37
|
// pointer to the underlying data.
|
|
40
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @suppress
|
|
41
|
+
*/
|
|
41
42
|
@Structure.FieldOrder("capacity", "len", "data")
|
|
42
43
|
open class RustBuffer : Structure() {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
// Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values.
|
|
45
|
+
// When dealing with these fields, make sure to call `toULong()`.
|
|
46
|
+
@JvmField var capacity: Long = 0
|
|
47
|
+
@JvmField var len: Long = 0
|
|
45
48
|
@JvmField var data: Pointer? = null
|
|
46
49
|
|
|
47
50
|
class ByValue: RustBuffer(), Structure.ByValue
|
|
48
51
|
class ByReference: RustBuffer(), Structure.ByReference
|
|
49
52
|
|
|
53
|
+
internal fun setValue(other: RustBuffer) {
|
|
54
|
+
capacity = other.capacity
|
|
55
|
+
len = other.len
|
|
56
|
+
data = other.data
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
companion object {
|
|
51
|
-
internal fun alloc(size:
|
|
52
|
-
|
|
60
|
+
internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status ->
|
|
61
|
+
// Note: need to convert the size to a `Long` value to make this work with JVM.
|
|
62
|
+
UniffiLib.INSTANCE.ffi_pubkycore_rustbuffer_alloc(size.toLong(), status)
|
|
53
63
|
}.also {
|
|
54
64
|
if(it.data == null) {
|
|
55
65
|
throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
internal fun create(capacity:
|
|
69
|
+
internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue {
|
|
60
70
|
var buf = RustBuffer.ByValue()
|
|
61
|
-
buf.capacity = capacity
|
|
62
|
-
buf.len = len
|
|
71
|
+
buf.capacity = capacity.toLong()
|
|
72
|
+
buf.len = len.toLong()
|
|
63
73
|
buf.data = data
|
|
64
74
|
return buf
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
internal fun free(buf: RustBuffer.ByValue) =
|
|
68
|
-
|
|
77
|
+
internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status ->
|
|
78
|
+
UniffiLib.INSTANCE.ffi_pubkycore_rustbuffer_free(buf, status)
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
@@ -81,6 +91,8 @@ open class RustBuffer : Structure() {
|
|
|
81
91
|
* Required for callbacks taking in an out pointer.
|
|
82
92
|
*
|
|
83
93
|
* Size is the sum of all values in the struct.
|
|
94
|
+
*
|
|
95
|
+
* @suppress
|
|
84
96
|
*/
|
|
85
97
|
class RustBufferByReference : ByReference(16) {
|
|
86
98
|
/**
|
|
@@ -89,9 +101,9 @@ class RustBufferByReference : ByReference(16) {
|
|
|
89
101
|
fun setValue(value: RustBuffer.ByValue) {
|
|
90
102
|
// NOTE: The offsets are as they are in the C-like struct.
|
|
91
103
|
val pointer = getPointer()
|
|
92
|
-
pointer.
|
|
93
|
-
pointer.
|
|
94
|
-
pointer.setPointer(
|
|
104
|
+
pointer.setLong(0, value.capacity)
|
|
105
|
+
pointer.setLong(8, value.len)
|
|
106
|
+
pointer.setPointer(16, value.data)
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
/**
|
|
@@ -100,9 +112,9 @@ class RustBufferByReference : ByReference(16) {
|
|
|
100
112
|
fun getValue(): RustBuffer.ByValue {
|
|
101
113
|
val pointer = getPointer()
|
|
102
114
|
val value = RustBuffer.ByValue()
|
|
103
|
-
value.writeField("capacity", pointer.
|
|
104
|
-
value.writeField("len", pointer.
|
|
105
|
-
value.writeField("data", pointer.
|
|
115
|
+
value.writeField("capacity", pointer.getLong(0))
|
|
116
|
+
value.writeField("len", pointer.getLong(8))
|
|
117
|
+
value.writeField("data", pointer.getLong(16))
|
|
106
118
|
|
|
107
119
|
return value
|
|
108
120
|
}
|
|
@@ -115,16 +127,20 @@ class RustBufferByReference : ByReference(16) {
|
|
|
115
127
|
// completeness.
|
|
116
128
|
|
|
117
129
|
@Structure.FieldOrder("len", "data")
|
|
118
|
-
open class ForeignBytes : Structure() {
|
|
130
|
+
internal open class ForeignBytes : Structure() {
|
|
119
131
|
@JvmField var len: Int = 0
|
|
120
132
|
@JvmField var data: Pointer? = null
|
|
121
133
|
|
|
122
134
|
class ByValue : ForeignBytes(), Structure.ByValue
|
|
123
135
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
136
|
+
/**
|
|
137
|
+
* The FfiConverter interface handles converter types to and from the FFI
|
|
138
|
+
*
|
|
139
|
+
* All implementing objects should be public to support external types. When a
|
|
140
|
+
* type is external we need to import it's FfiConverter.
|
|
141
|
+
*
|
|
142
|
+
* @suppress
|
|
143
|
+
*/
|
|
128
144
|
public interface FfiConverter<KotlinType, FfiType> {
|
|
129
145
|
// Convert an FFI type to a Kotlin type
|
|
130
146
|
fun lift(value: FfiType): KotlinType
|
|
@@ -143,7 +159,7 @@ public interface FfiConverter<KotlinType, FfiType> {
|
|
|
143
159
|
// encoding, so we pessimistically allocate the largest size possible (3
|
|
144
160
|
// bytes per codepoint). Allocating extra bytes is not really a big deal
|
|
145
161
|
// because the `RustBuffer` is short-lived.
|
|
146
|
-
fun allocationSize(value: KotlinType):
|
|
162
|
+
fun allocationSize(value: KotlinType): ULong
|
|
147
163
|
|
|
148
164
|
// Write a Kotlin type to a `ByteBuffer`
|
|
149
165
|
fun write(value: KotlinType, buf: ByteBuffer)
|
|
@@ -157,11 +173,11 @@ public interface FfiConverter<KotlinType, FfiType> {
|
|
|
157
173
|
fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
|
|
158
174
|
val rbuf = RustBuffer.alloc(allocationSize(value))
|
|
159
175
|
try {
|
|
160
|
-
val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity
|
|
176
|
+
val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also {
|
|
161
177
|
it.order(ByteOrder.BIG_ENDIAN)
|
|
162
178
|
}
|
|
163
179
|
write(value, bbuf)
|
|
164
|
-
rbuf.writeField("len", bbuf.position())
|
|
180
|
+
rbuf.writeField("len", bbuf.position().toLong())
|
|
165
181
|
return rbuf
|
|
166
182
|
} catch (e: Throwable) {
|
|
167
183
|
RustBuffer.free(rbuf)
|
|
@@ -187,38 +203,59 @@ public interface FfiConverter<KotlinType, FfiType> {
|
|
|
187
203
|
}
|
|
188
204
|
}
|
|
189
205
|
|
|
190
|
-
|
|
206
|
+
/**
|
|
207
|
+
* FfiConverter that uses `RustBuffer` as the FfiType
|
|
208
|
+
*
|
|
209
|
+
* @suppress
|
|
210
|
+
*/
|
|
191
211
|
public interface FfiConverterRustBuffer<KotlinType>: FfiConverter<KotlinType, RustBuffer.ByValue> {
|
|
192
212
|
override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
|
|
193
213
|
override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
|
|
194
214
|
}
|
|
195
215
|
// A handful of classes and functions to support the generated data structures.
|
|
196
216
|
// This would be a good candidate for isolating in its own ffi-support lib.
|
|
197
|
-
|
|
217
|
+
|
|
218
|
+
internal const val UNIFFI_CALL_SUCCESS = 0.toByte()
|
|
219
|
+
internal const val UNIFFI_CALL_ERROR = 1.toByte()
|
|
220
|
+
internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
|
|
221
|
+
|
|
198
222
|
@Structure.FieldOrder("code", "error_buf")
|
|
199
|
-
internal open class
|
|
223
|
+
internal open class UniffiRustCallStatus : Structure() {
|
|
200
224
|
@JvmField var code: Byte = 0
|
|
201
225
|
@JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
|
|
202
226
|
|
|
203
|
-
class ByValue:
|
|
227
|
+
class ByValue: UniffiRustCallStatus(), Structure.ByValue
|
|
204
228
|
|
|
205
229
|
fun isSuccess(): Boolean {
|
|
206
|
-
return code ==
|
|
230
|
+
return code == UNIFFI_CALL_SUCCESS
|
|
207
231
|
}
|
|
208
232
|
|
|
209
233
|
fun isError(): Boolean {
|
|
210
|
-
return code ==
|
|
234
|
+
return code == UNIFFI_CALL_ERROR
|
|
211
235
|
}
|
|
212
236
|
|
|
213
237
|
fun isPanic(): Boolean {
|
|
214
|
-
return code ==
|
|
238
|
+
return code == UNIFFI_CALL_UNEXPECTED_ERROR
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
companion object {
|
|
242
|
+
fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue {
|
|
243
|
+
val callStatus = UniffiRustCallStatus.ByValue()
|
|
244
|
+
callStatus.code = code
|
|
245
|
+
callStatus.error_buf = errorBuf
|
|
246
|
+
return callStatus
|
|
247
|
+
}
|
|
215
248
|
}
|
|
216
249
|
}
|
|
217
250
|
|
|
218
|
-
class InternalException(message: String) : Exception(message)
|
|
251
|
+
class InternalException(message: String) : kotlin.Exception(message)
|
|
219
252
|
|
|
220
|
-
|
|
221
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Each top-level error class has a companion object that can lift the error from the call status's rust buffer
|
|
255
|
+
*
|
|
256
|
+
* @suppress
|
|
257
|
+
*/
|
|
258
|
+
interface UniffiRustCallStatusErrorHandler<E> {
|
|
222
259
|
fun lift(error_buf: RustBuffer.ByValue): E;
|
|
223
260
|
}
|
|
224
261
|
|
|
@@ -227,15 +264,15 @@ interface CallStatusErrorHandler<E> {
|
|
|
227
264
|
// synchronize itself
|
|
228
265
|
|
|
229
266
|
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
|
|
230
|
-
private inline fun <U, E: Exception>
|
|
231
|
-
var status =
|
|
267
|
+
private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
|
|
268
|
+
var status = UniffiRustCallStatus()
|
|
232
269
|
val return_value = callback(status)
|
|
233
|
-
|
|
270
|
+
uniffiCheckCallStatus(errorHandler, status)
|
|
234
271
|
return return_value
|
|
235
272
|
}
|
|
236
273
|
|
|
237
|
-
// Check
|
|
238
|
-
private fun<E: Exception>
|
|
274
|
+
// Check UniffiRustCallStatus and throw an error if the call wasn't successful
|
|
275
|
+
private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
|
|
239
276
|
if (status.isSuccess()) {
|
|
240
277
|
return
|
|
241
278
|
} else if (status.isError()) {
|
|
@@ -254,8 +291,12 @@ private fun<E: Exception> checkCallStatus(errorHandler: CallStatusErrorHandler<E
|
|
|
254
291
|
}
|
|
255
292
|
}
|
|
256
293
|
|
|
257
|
-
|
|
258
|
-
|
|
294
|
+
/**
|
|
295
|
+
* UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
|
|
296
|
+
*
|
|
297
|
+
* @suppress
|
|
298
|
+
*/
|
|
299
|
+
object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<InternalException> {
|
|
259
300
|
override fun lift(error_buf: RustBuffer.ByValue): InternalException {
|
|
260
301
|
RustBuffer.free(error_buf)
|
|
261
302
|
return InternalException("Unexpected CALL_ERROR")
|
|
@@ -263,97 +304,69 @@ object NullCallStatusErrorHandler: CallStatusErrorHandler<InternalException> {
|
|
|
263
304
|
}
|
|
264
305
|
|
|
265
306
|
// Call a rust function that returns a plain value
|
|
266
|
-
private inline fun <U>
|
|
267
|
-
return
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// Make sure we always write usize integers using native byte-order, since they may be
|
|
281
|
-
// casted to pointer values
|
|
282
|
-
buf.order(ByteOrder.nativeOrder())
|
|
283
|
-
try {
|
|
284
|
-
when (Native.SIZE_T_SIZE) {
|
|
285
|
-
4 -> buf.putInt(toInt())
|
|
286
|
-
8 -> buf.putLong(toLong())
|
|
287
|
-
else -> throw RuntimeException("Invalid SIZE_T_SIZE: ${Native.SIZE_T_SIZE}")
|
|
288
|
-
}
|
|
289
|
-
} finally {
|
|
290
|
-
buf.order(ByteOrder.BIG_ENDIAN)
|
|
291
|
-
}
|
|
307
|
+
private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
|
|
308
|
+
return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
internal inline fun<T> uniffiTraitInterfaceCall(
|
|
312
|
+
callStatus: UniffiRustCallStatus,
|
|
313
|
+
makeCall: () -> T,
|
|
314
|
+
writeReturn: (T) -> Unit,
|
|
315
|
+
) {
|
|
316
|
+
try {
|
|
317
|
+
writeReturn(makeCall())
|
|
318
|
+
} catch(e: kotlin.Exception) {
|
|
319
|
+
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
|
|
320
|
+
callStatus.error_buf = FfiConverterString.lower(e.toString())
|
|
292
321
|
}
|
|
322
|
+
}
|
|
293
323
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
buf.order(ByteOrder.BIG_ENDIAN)
|
|
310
|
-
}
|
|
324
|
+
internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
|
|
325
|
+
callStatus: UniffiRustCallStatus,
|
|
326
|
+
makeCall: () -> T,
|
|
327
|
+
writeReturn: (T) -> Unit,
|
|
328
|
+
lowerError: (E) -> RustBuffer.ByValue
|
|
329
|
+
) {
|
|
330
|
+
try {
|
|
331
|
+
writeReturn(makeCall())
|
|
332
|
+
} catch(e: kotlin.Exception) {
|
|
333
|
+
if (e is E) {
|
|
334
|
+
callStatus.code = UNIFFI_CALL_ERROR
|
|
335
|
+
callStatus.error_buf = lowerError(e)
|
|
336
|
+
} else {
|
|
337
|
+
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
|
|
338
|
+
callStatus.error_buf = FfiConverterString.lower(e.toString())
|
|
311
339
|
}
|
|
312
340
|
}
|
|
313
341
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
342
|
// Map handles to objects
|
|
317
343
|
//
|
|
318
|
-
// This is used
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
// Instead, this class maps USize values to objects so that we can pass a pointer-sized type to
|
|
323
|
-
// Rust when it needs an opaque pointer.
|
|
324
|
-
//
|
|
325
|
-
// TODO: refactor callbacks to use this class
|
|
326
|
-
internal class UniFfiHandleMap<T: Any> {
|
|
327
|
-
private val map = ConcurrentHashMap<USize, T>()
|
|
328
|
-
// Use AtomicInteger for our counter, since we may be on a 32-bit system. 4 billion possible
|
|
329
|
-
// values seems like enough. If somehow we generate 4 billion handles, then this will wrap
|
|
330
|
-
// around back to zero and we can assume the first handle generated will have been dropped by
|
|
331
|
-
// then.
|
|
332
|
-
private val counter = java.util.concurrent.atomic.AtomicInteger(0)
|
|
344
|
+
// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.
|
|
345
|
+
internal class UniffiHandleMap<T: Any> {
|
|
346
|
+
private val map = ConcurrentHashMap<Long, T>()
|
|
347
|
+
private val counter = java.util.concurrent.atomic.AtomicLong(0)
|
|
333
348
|
|
|
334
349
|
val size: Int
|
|
335
350
|
get() = map.size
|
|
336
351
|
|
|
337
|
-
|
|
338
|
-
|
|
352
|
+
// Insert a new object into the handle map and get a handle for it
|
|
353
|
+
fun insert(obj: T): Long {
|
|
354
|
+
val handle = counter.getAndAdd(1)
|
|
339
355
|
map.put(handle, obj)
|
|
340
356
|
return handle
|
|
341
357
|
}
|
|
342
358
|
|
|
343
|
-
|
|
344
|
-
|
|
359
|
+
// Get an object from the handle map
|
|
360
|
+
fun get(handle: Long): T {
|
|
361
|
+
return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle")
|
|
345
362
|
}
|
|
346
363
|
|
|
347
|
-
|
|
348
|
-
|
|
364
|
+
// Remove an entry from the handlemap and get the Kotlin object back
|
|
365
|
+
fun remove(handle: Long): T {
|
|
366
|
+
return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle")
|
|
349
367
|
}
|
|
350
368
|
}
|
|
351
369
|
|
|
352
|
-
// FFI type for Rust future continuations
|
|
353
|
-
internal interface UniFffiRustFutureContinuationCallbackType : com.sun.jna.Callback {
|
|
354
|
-
fun callback(continuationHandle: USize, pollResult: Short);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
370
|
// Contains loading, initialization code,
|
|
358
371
|
// and the FFI Function declarations in a com.sun.jna.Library.
|
|
359
372
|
@Synchronized
|
|
@@ -371,364 +384,988 @@ private inline fun <reified Lib : Library> loadIndirect(
|
|
|
371
384
|
return Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
|
|
372
385
|
}
|
|
373
386
|
|
|
387
|
+
// Define FFI callback types
|
|
388
|
+
internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {
|
|
389
|
+
fun callback(`data`: Long,`pollResult`: Byte,)
|
|
390
|
+
}
|
|
391
|
+
internal interface UniffiForeignFutureFree : com.sun.jna.Callback {
|
|
392
|
+
fun callback(`handle`: Long,)
|
|
393
|
+
}
|
|
394
|
+
internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {
|
|
395
|
+
fun callback(`handle`: Long,)
|
|
396
|
+
}
|
|
397
|
+
@Structure.FieldOrder("handle", "free")
|
|
398
|
+
internal open class UniffiForeignFuture(
|
|
399
|
+
@JvmField internal var `handle`: Long = 0.toLong(),
|
|
400
|
+
@JvmField internal var `free`: UniffiForeignFutureFree? = null,
|
|
401
|
+
) : Structure() {
|
|
402
|
+
class UniffiByValue(
|
|
403
|
+
`handle`: Long = 0.toLong(),
|
|
404
|
+
`free`: UniffiForeignFutureFree? = null,
|
|
405
|
+
): UniffiForeignFuture(`handle`,`free`,), Structure.ByValue
|
|
406
|
+
|
|
407
|
+
internal fun uniffiSetValue(other: UniffiForeignFuture) {
|
|
408
|
+
`handle` = other.`handle`
|
|
409
|
+
`free` = other.`free`
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
414
|
+
internal open class UniffiForeignFutureStructU8(
|
|
415
|
+
@JvmField internal var `returnValue`: Byte = 0.toByte(),
|
|
416
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
417
|
+
) : Structure() {
|
|
418
|
+
class UniffiByValue(
|
|
419
|
+
`returnValue`: Byte = 0.toByte(),
|
|
420
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
421
|
+
): UniffiForeignFutureStructU8(`returnValue`,`callStatus`,), Structure.ByValue
|
|
422
|
+
|
|
423
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) {
|
|
424
|
+
`returnValue` = other.`returnValue`
|
|
425
|
+
`callStatus` = other.`callStatus`
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
}
|
|
429
|
+
internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {
|
|
430
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU8.UniffiByValue,)
|
|
431
|
+
}
|
|
432
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
433
|
+
internal open class UniffiForeignFutureStructI8(
|
|
434
|
+
@JvmField internal var `returnValue`: Byte = 0.toByte(),
|
|
435
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
436
|
+
) : Structure() {
|
|
437
|
+
class UniffiByValue(
|
|
438
|
+
`returnValue`: Byte = 0.toByte(),
|
|
439
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
440
|
+
): UniffiForeignFutureStructI8(`returnValue`,`callStatus`,), Structure.ByValue
|
|
441
|
+
|
|
442
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) {
|
|
443
|
+
`returnValue` = other.`returnValue`
|
|
444
|
+
`callStatus` = other.`callStatus`
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {
|
|
449
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI8.UniffiByValue,)
|
|
450
|
+
}
|
|
451
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
452
|
+
internal open class UniffiForeignFutureStructU16(
|
|
453
|
+
@JvmField internal var `returnValue`: Short = 0.toShort(),
|
|
454
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
455
|
+
) : Structure() {
|
|
456
|
+
class UniffiByValue(
|
|
457
|
+
`returnValue`: Short = 0.toShort(),
|
|
458
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
459
|
+
): UniffiForeignFutureStructU16(`returnValue`,`callStatus`,), Structure.ByValue
|
|
460
|
+
|
|
461
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) {
|
|
462
|
+
`returnValue` = other.`returnValue`
|
|
463
|
+
`callStatus` = other.`callStatus`
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {
|
|
468
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU16.UniffiByValue,)
|
|
469
|
+
}
|
|
470
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
471
|
+
internal open class UniffiForeignFutureStructI16(
|
|
472
|
+
@JvmField internal var `returnValue`: Short = 0.toShort(),
|
|
473
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
474
|
+
) : Structure() {
|
|
475
|
+
class UniffiByValue(
|
|
476
|
+
`returnValue`: Short = 0.toShort(),
|
|
477
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
478
|
+
): UniffiForeignFutureStructI16(`returnValue`,`callStatus`,), Structure.ByValue
|
|
479
|
+
|
|
480
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) {
|
|
481
|
+
`returnValue` = other.`returnValue`
|
|
482
|
+
`callStatus` = other.`callStatus`
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
}
|
|
486
|
+
internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {
|
|
487
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI16.UniffiByValue,)
|
|
488
|
+
}
|
|
489
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
490
|
+
internal open class UniffiForeignFutureStructU32(
|
|
491
|
+
@JvmField internal var `returnValue`: Int = 0,
|
|
492
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
493
|
+
) : Structure() {
|
|
494
|
+
class UniffiByValue(
|
|
495
|
+
`returnValue`: Int = 0,
|
|
496
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
497
|
+
): UniffiForeignFutureStructU32(`returnValue`,`callStatus`,), Structure.ByValue
|
|
498
|
+
|
|
499
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) {
|
|
500
|
+
`returnValue` = other.`returnValue`
|
|
501
|
+
`callStatus` = other.`callStatus`
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {
|
|
506
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU32.UniffiByValue,)
|
|
507
|
+
}
|
|
508
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
509
|
+
internal open class UniffiForeignFutureStructI32(
|
|
510
|
+
@JvmField internal var `returnValue`: Int = 0,
|
|
511
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
512
|
+
) : Structure() {
|
|
513
|
+
class UniffiByValue(
|
|
514
|
+
`returnValue`: Int = 0,
|
|
515
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
516
|
+
): UniffiForeignFutureStructI32(`returnValue`,`callStatus`,), Structure.ByValue
|
|
517
|
+
|
|
518
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) {
|
|
519
|
+
`returnValue` = other.`returnValue`
|
|
520
|
+
`callStatus` = other.`callStatus`
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
}
|
|
524
|
+
internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {
|
|
525
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI32.UniffiByValue,)
|
|
526
|
+
}
|
|
527
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
528
|
+
internal open class UniffiForeignFutureStructU64(
|
|
529
|
+
@JvmField internal var `returnValue`: Long = 0.toLong(),
|
|
530
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
531
|
+
) : Structure() {
|
|
532
|
+
class UniffiByValue(
|
|
533
|
+
`returnValue`: Long = 0.toLong(),
|
|
534
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
535
|
+
): UniffiForeignFutureStructU64(`returnValue`,`callStatus`,), Structure.ByValue
|
|
536
|
+
|
|
537
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) {
|
|
538
|
+
`returnValue` = other.`returnValue`
|
|
539
|
+
`callStatus` = other.`callStatus`
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {
|
|
544
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU64.UniffiByValue,)
|
|
545
|
+
}
|
|
546
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
547
|
+
internal open class UniffiForeignFutureStructI64(
|
|
548
|
+
@JvmField internal var `returnValue`: Long = 0.toLong(),
|
|
549
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
550
|
+
) : Structure() {
|
|
551
|
+
class UniffiByValue(
|
|
552
|
+
`returnValue`: Long = 0.toLong(),
|
|
553
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
554
|
+
): UniffiForeignFutureStructI64(`returnValue`,`callStatus`,), Structure.ByValue
|
|
555
|
+
|
|
556
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) {
|
|
557
|
+
`returnValue` = other.`returnValue`
|
|
558
|
+
`callStatus` = other.`callStatus`
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {
|
|
563
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI64.UniffiByValue,)
|
|
564
|
+
}
|
|
565
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
566
|
+
internal open class UniffiForeignFutureStructF32(
|
|
567
|
+
@JvmField internal var `returnValue`: Float = 0.0f,
|
|
568
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
569
|
+
) : Structure() {
|
|
570
|
+
class UniffiByValue(
|
|
571
|
+
`returnValue`: Float = 0.0f,
|
|
572
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
573
|
+
): UniffiForeignFutureStructF32(`returnValue`,`callStatus`,), Structure.ByValue
|
|
574
|
+
|
|
575
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) {
|
|
576
|
+
`returnValue` = other.`returnValue`
|
|
577
|
+
`callStatus` = other.`callStatus`
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {
|
|
582
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF32.UniffiByValue,)
|
|
583
|
+
}
|
|
584
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
585
|
+
internal open class UniffiForeignFutureStructF64(
|
|
586
|
+
@JvmField internal var `returnValue`: Double = 0.0,
|
|
587
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
588
|
+
) : Structure() {
|
|
589
|
+
class UniffiByValue(
|
|
590
|
+
`returnValue`: Double = 0.0,
|
|
591
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
592
|
+
): UniffiForeignFutureStructF64(`returnValue`,`callStatus`,), Structure.ByValue
|
|
593
|
+
|
|
594
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) {
|
|
595
|
+
`returnValue` = other.`returnValue`
|
|
596
|
+
`callStatus` = other.`callStatus`
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {
|
|
601
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF64.UniffiByValue,)
|
|
602
|
+
}
|
|
603
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
604
|
+
internal open class UniffiForeignFutureStructPointer(
|
|
605
|
+
@JvmField internal var `returnValue`: Pointer = Pointer.NULL,
|
|
606
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
607
|
+
) : Structure() {
|
|
608
|
+
class UniffiByValue(
|
|
609
|
+
`returnValue`: Pointer = Pointer.NULL,
|
|
610
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
611
|
+
): UniffiForeignFutureStructPointer(`returnValue`,`callStatus`,), Structure.ByValue
|
|
612
|
+
|
|
613
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) {
|
|
614
|
+
`returnValue` = other.`returnValue`
|
|
615
|
+
`callStatus` = other.`callStatus`
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
}
|
|
619
|
+
internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback {
|
|
620
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructPointer.UniffiByValue,)
|
|
621
|
+
}
|
|
622
|
+
@Structure.FieldOrder("returnValue", "callStatus")
|
|
623
|
+
internal open class UniffiForeignFutureStructRustBuffer(
|
|
624
|
+
@JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
|
|
625
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
626
|
+
) : Structure() {
|
|
627
|
+
class UniffiByValue(
|
|
628
|
+
`returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
|
|
629
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
630
|
+
): UniffiForeignFutureStructRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue
|
|
631
|
+
|
|
632
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) {
|
|
633
|
+
`returnValue` = other.`returnValue`
|
|
634
|
+
`callStatus` = other.`callStatus`
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
}
|
|
638
|
+
internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {
|
|
639
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,)
|
|
640
|
+
}
|
|
641
|
+
@Structure.FieldOrder("callStatus")
|
|
642
|
+
internal open class UniffiForeignFutureStructVoid(
|
|
643
|
+
@JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
644
|
+
) : Structure() {
|
|
645
|
+
class UniffiByValue(
|
|
646
|
+
`callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
|
|
647
|
+
): UniffiForeignFutureStructVoid(`callStatus`,), Structure.ByValue
|
|
648
|
+
|
|
649
|
+
internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) {
|
|
650
|
+
`callStatus` = other.`callStatus`
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
}
|
|
654
|
+
internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
|
|
655
|
+
fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructVoid.UniffiByValue,)
|
|
656
|
+
}
|
|
657
|
+
internal interface UniffiCallbackInterfaceEventListenerMethod0 : com.sun.jna.Callback {
|
|
658
|
+
fun callback(`uniffiHandle`: Long,`eventData`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,)
|
|
659
|
+
}
|
|
660
|
+
@Structure.FieldOrder("onEventOccurred", "uniffiFree")
|
|
661
|
+
internal open class UniffiVTableCallbackInterfaceEventListener(
|
|
662
|
+
@JvmField internal var `onEventOccurred`: UniffiCallbackInterfaceEventListenerMethod0? = null,
|
|
663
|
+
@JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null,
|
|
664
|
+
) : Structure() {
|
|
665
|
+
class UniffiByValue(
|
|
666
|
+
`onEventOccurred`: UniffiCallbackInterfaceEventListenerMethod0? = null,
|
|
667
|
+
`uniffiFree`: UniffiCallbackInterfaceFree? = null,
|
|
668
|
+
): UniffiVTableCallbackInterfaceEventListener(`onEventOccurred`,`uniffiFree`,), Structure.ByValue
|
|
669
|
+
|
|
670
|
+
internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceEventListener) {
|
|
671
|
+
`onEventOccurred` = other.`onEventOccurred`
|
|
672
|
+
`uniffiFree` = other.`uniffiFree`
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
// For large crates we prevent `MethodTooLargeException` (see #2340)
|
|
795
|
+
// N.B. the name of the extension is very misleading, since it is
|
|
796
|
+
// rather `InterfaceTooLargeException`, caused by too many methods
|
|
797
|
+
// in the interface for large crates.
|
|
798
|
+
//
|
|
799
|
+
// By splitting the otherwise huge interface into two parts
|
|
800
|
+
// * UniffiLib
|
|
801
|
+
// * IntegrityCheckingUniffiLib (this)
|
|
802
|
+
// we allow for ~2x as many methods in the UniffiLib interface.
|
|
803
|
+
//
|
|
804
|
+
// The `ffi_uniffi_contract_version` method and all checksum methods are put
|
|
805
|
+
// into `IntegrityCheckingUniffiLib` and these methods are called only once,
|
|
806
|
+
// when the library is loaded.
|
|
807
|
+
internal interface IntegrityCheckingUniffiLib : Library {
|
|
808
|
+
// Integrity check functions only
|
|
809
|
+
fun uniffi_pubkycore_checksum_func_auth(
|
|
810
|
+
): Short
|
|
811
|
+
fun uniffi_pubkycore_checksum_func_create_recovery_file(
|
|
812
|
+
): Short
|
|
813
|
+
fun uniffi_pubkycore_checksum_func_decrypt_recovery_file(
|
|
814
|
+
): Short
|
|
815
|
+
fun uniffi_pubkycore_checksum_func_delete_file(
|
|
816
|
+
): Short
|
|
817
|
+
fun uniffi_pubkycore_checksum_func_generate_mnemonic_phrase(
|
|
818
|
+
): Short
|
|
819
|
+
fun uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair(
|
|
820
|
+
): Short
|
|
821
|
+
fun uniffi_pubkycore_checksum_func_generate_secret_key(
|
|
822
|
+
): Short
|
|
823
|
+
fun uniffi_pubkycore_checksum_func_get(
|
|
824
|
+
): Short
|
|
825
|
+
fun uniffi_pubkycore_checksum_func_get_homeserver(
|
|
826
|
+
): Short
|
|
827
|
+
fun uniffi_pubkycore_checksum_func_get_public_key_from_secret_key(
|
|
828
|
+
): Short
|
|
829
|
+
fun uniffi_pubkycore_checksum_func_get_signup_token(
|
|
830
|
+
): Short
|
|
831
|
+
fun uniffi_pubkycore_checksum_func_list(
|
|
832
|
+
): Short
|
|
833
|
+
fun uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair(
|
|
834
|
+
): Short
|
|
835
|
+
fun uniffi_pubkycore_checksum_func_parse_auth_url(
|
|
836
|
+
): Short
|
|
837
|
+
fun uniffi_pubkycore_checksum_func_publish(
|
|
838
|
+
): Short
|
|
839
|
+
fun uniffi_pubkycore_checksum_func_publish_https(
|
|
840
|
+
): Short
|
|
841
|
+
fun uniffi_pubkycore_checksum_func_put(
|
|
842
|
+
): Short
|
|
843
|
+
fun uniffi_pubkycore_checksum_func_remove_event_listener(
|
|
844
|
+
): Short
|
|
845
|
+
fun uniffi_pubkycore_checksum_func_republish_homeserver(
|
|
846
|
+
): Short
|
|
847
|
+
fun uniffi_pubkycore_checksum_func_resolve(
|
|
848
|
+
): Short
|
|
849
|
+
fun uniffi_pubkycore_checksum_func_resolve_https(
|
|
850
|
+
): Short
|
|
851
|
+
fun uniffi_pubkycore_checksum_func_revalidate_session(
|
|
852
|
+
): Short
|
|
853
|
+
fun uniffi_pubkycore_checksum_func_set_event_listener(
|
|
854
|
+
): Short
|
|
855
|
+
fun uniffi_pubkycore_checksum_func_sign_in(
|
|
856
|
+
): Short
|
|
857
|
+
fun uniffi_pubkycore_checksum_func_sign_out(
|
|
858
|
+
): Short
|
|
859
|
+
fun uniffi_pubkycore_checksum_func_sign_up(
|
|
860
|
+
): Short
|
|
861
|
+
fun uniffi_pubkycore_checksum_func_switch_network(
|
|
862
|
+
): Short
|
|
863
|
+
fun uniffi_pubkycore_checksum_func_validate_mnemonic_phrase(
|
|
864
|
+
): Short
|
|
865
|
+
fun uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred(
|
|
866
|
+
): Short
|
|
867
|
+
fun ffi_pubkycore_uniffi_contract_version(
|
|
868
|
+
): Int
|
|
869
|
+
|
|
870
|
+
}
|
|
871
|
+
|
|
374
872
|
// A JNA Library to expose the extern-C FFI definitions.
|
|
375
873
|
// This is an implementation detail which will be called internally by the public API.
|
|
376
|
-
|
|
377
|
-
internal interface _UniFFILib : Library {
|
|
874
|
+
internal interface UniffiLib : Library {
|
|
378
875
|
companion object {
|
|
379
|
-
internal val INSTANCE:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
876
|
+
internal val INSTANCE: UniffiLib by lazy {
|
|
877
|
+
val componentName = "pubkycore"
|
|
878
|
+
// For large crates we prevent `MethodTooLargeException` (see #2340)
|
|
879
|
+
// N.B. the name of the extension is very misleading, since it is
|
|
880
|
+
// rather `InterfaceTooLargeException`, caused by too many methods
|
|
881
|
+
// in the interface for large crates.
|
|
882
|
+
//
|
|
883
|
+
// By splitting the otherwise huge interface into two parts
|
|
884
|
+
// * UniffiLib (this)
|
|
885
|
+
// * IntegrityCheckingUniffiLib
|
|
886
|
+
// And all checksum methods are put into `IntegrityCheckingUniffiLib`
|
|
887
|
+
// we allow for ~2x as many methods in the UniffiLib interface.
|
|
888
|
+
//
|
|
889
|
+
// Thus we first load the library with `loadIndirect` as `IntegrityCheckingUniffiLib`
|
|
890
|
+
// so that we can (optionally!) call `uniffiCheckApiChecksums`...
|
|
891
|
+
loadIndirect<IntegrityCheckingUniffiLib>(componentName)
|
|
892
|
+
.also { lib: IntegrityCheckingUniffiLib ->
|
|
893
|
+
uniffiCheckContractApiVersion(lib)
|
|
894
|
+
uniffiCheckApiChecksums(lib)
|
|
385
895
|
}
|
|
896
|
+
// ... and then we load the library as `UniffiLib`
|
|
897
|
+
// N.B. we cannot use `loadIndirect` once and then try to cast it to `UniffiLib`
|
|
898
|
+
// => results in `java.lang.ClassCastException: com.sun.proxy.$Proxy cannot be cast to ...`
|
|
899
|
+
// error. So we must call `loadIndirect` twice. For crates large enough
|
|
900
|
+
// to trigger this issue, the performance impact is negligible, running on
|
|
901
|
+
// a macOS M1 machine the `loadIndirect` call takes ~50ms.
|
|
902
|
+
val lib = loadIndirect<UniffiLib>(componentName)
|
|
903
|
+
// No need to check the contract version and checksums, since
|
|
904
|
+
// we already did that with `IntegrityCheckingUniffiLib` above.
|
|
905
|
+
uniffiCallbackInterfaceEventListener.register(lib)
|
|
906
|
+
// Loading of library with integrity check done.
|
|
907
|
+
lib
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// The Cleaner for the whole library
|
|
911
|
+
internal val CLEANER: UniffiCleaner by lazy {
|
|
912
|
+
UniffiCleaner.create()
|
|
386
913
|
}
|
|
387
914
|
}
|
|
388
915
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
fun uniffi_pubkycore_checksum_func_create_recovery_file(
|
|
566
|
-
): Short
|
|
567
|
-
fun uniffi_pubkycore_checksum_func_decrypt_recovery_file(
|
|
568
|
-
): Short
|
|
569
|
-
fun uniffi_pubkycore_checksum_func_delete_file(
|
|
570
|
-
): Short
|
|
571
|
-
fun uniffi_pubkycore_checksum_func_generate_mnemonic_phrase(
|
|
572
|
-
): Short
|
|
573
|
-
fun uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair(
|
|
574
|
-
): Short
|
|
575
|
-
fun uniffi_pubkycore_checksum_func_generate_secret_key(
|
|
576
|
-
): Short
|
|
577
|
-
fun uniffi_pubkycore_checksum_func_get(
|
|
578
|
-
): Short
|
|
579
|
-
fun uniffi_pubkycore_checksum_func_get_homeserver(
|
|
580
|
-
): Short
|
|
581
|
-
fun uniffi_pubkycore_checksum_func_get_public_key_from_secret_key(
|
|
582
|
-
): Short
|
|
583
|
-
fun uniffi_pubkycore_checksum_func_get_signup_token(
|
|
584
|
-
): Short
|
|
585
|
-
fun uniffi_pubkycore_checksum_func_list(
|
|
586
|
-
): Short
|
|
587
|
-
fun uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair(
|
|
588
|
-
): Short
|
|
589
|
-
fun uniffi_pubkycore_checksum_func_parse_auth_url(
|
|
590
|
-
): Short
|
|
591
|
-
fun uniffi_pubkycore_checksum_func_publish(
|
|
592
|
-
): Short
|
|
593
|
-
fun uniffi_pubkycore_checksum_func_publish_https(
|
|
594
|
-
): Short
|
|
595
|
-
fun uniffi_pubkycore_checksum_func_put(
|
|
596
|
-
): Short
|
|
597
|
-
fun uniffi_pubkycore_checksum_func_remove_event_listener(
|
|
598
|
-
): Short
|
|
599
|
-
fun uniffi_pubkycore_checksum_func_republish_homeserver(
|
|
600
|
-
): Short
|
|
601
|
-
fun uniffi_pubkycore_checksum_func_resolve(
|
|
602
|
-
): Short
|
|
603
|
-
fun uniffi_pubkycore_checksum_func_resolve_https(
|
|
604
|
-
): Short
|
|
605
|
-
fun uniffi_pubkycore_checksum_func_session(
|
|
606
|
-
): Short
|
|
607
|
-
fun uniffi_pubkycore_checksum_func_set_event_listener(
|
|
608
|
-
): Short
|
|
609
|
-
fun uniffi_pubkycore_checksum_func_sign_in(
|
|
610
|
-
): Short
|
|
611
|
-
fun uniffi_pubkycore_checksum_func_sign_out(
|
|
612
|
-
): Short
|
|
613
|
-
fun uniffi_pubkycore_checksum_func_sign_up(
|
|
614
|
-
): Short
|
|
615
|
-
fun uniffi_pubkycore_checksum_func_switch_network(
|
|
616
|
-
): Short
|
|
617
|
-
fun uniffi_pubkycore_checksum_func_validate_mnemonic_phrase(
|
|
618
|
-
): Short
|
|
619
|
-
fun uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred(
|
|
620
|
-
): Short
|
|
621
|
-
fun ffi_pubkycore_uniffi_contract_version(
|
|
622
|
-
): Int
|
|
623
|
-
|
|
916
|
+
// FFI functions
|
|
917
|
+
fun uniffi_pubkycore_fn_clone_eventnotifier(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
|
|
918
|
+
): Pointer
|
|
919
|
+
fun uniffi_pubkycore_fn_free_eventnotifier(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
|
|
920
|
+
): Unit
|
|
921
|
+
fun uniffi_pubkycore_fn_init_callback_vtable_eventlistener(`vtable`: UniffiVTableCallbackInterfaceEventListener,
|
|
922
|
+
): Unit
|
|
923
|
+
fun uniffi_pubkycore_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
924
|
+
): RustBuffer.ByValue
|
|
925
|
+
fun uniffi_pubkycore_fn_func_create_recovery_file(`secretKey`: RustBuffer.ByValue,`passphrase`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
926
|
+
): RustBuffer.ByValue
|
|
927
|
+
fun uniffi_pubkycore_fn_func_decrypt_recovery_file(`recoveryFile`: RustBuffer.ByValue,`passphrase`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
928
|
+
): RustBuffer.ByValue
|
|
929
|
+
fun uniffi_pubkycore_fn_func_delete_file(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
930
|
+
): RustBuffer.ByValue
|
|
931
|
+
fun uniffi_pubkycore_fn_func_generate_mnemonic_phrase(uniffi_out_err: UniffiRustCallStatus,
|
|
932
|
+
): RustBuffer.ByValue
|
|
933
|
+
fun uniffi_pubkycore_fn_func_generate_mnemonic_phrase_and_keypair(uniffi_out_err: UniffiRustCallStatus,
|
|
934
|
+
): RustBuffer.ByValue
|
|
935
|
+
fun uniffi_pubkycore_fn_func_generate_secret_key(uniffi_out_err: UniffiRustCallStatus,
|
|
936
|
+
): RustBuffer.ByValue
|
|
937
|
+
fun uniffi_pubkycore_fn_func_get(`url`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
938
|
+
): RustBuffer.ByValue
|
|
939
|
+
fun uniffi_pubkycore_fn_func_get_homeserver(`pubky`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
940
|
+
): RustBuffer.ByValue
|
|
941
|
+
fun uniffi_pubkycore_fn_func_get_public_key_from_secret_key(`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
942
|
+
): RustBuffer.ByValue
|
|
943
|
+
fun uniffi_pubkycore_fn_func_get_signup_token(`homeserverPubky`: RustBuffer.ByValue,`adminPassword`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
944
|
+
): RustBuffer.ByValue
|
|
945
|
+
fun uniffi_pubkycore_fn_func_list(`url`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
946
|
+
): RustBuffer.ByValue
|
|
947
|
+
fun uniffi_pubkycore_fn_func_mnemonic_phrase_to_keypair(`mnemonicPhrase`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
948
|
+
): RustBuffer.ByValue
|
|
949
|
+
fun uniffi_pubkycore_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
950
|
+
): RustBuffer.ByValue
|
|
951
|
+
fun uniffi_pubkycore_fn_func_publish(`recordName`: RustBuffer.ByValue,`recordContent`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
952
|
+
): RustBuffer.ByValue
|
|
953
|
+
fun uniffi_pubkycore_fn_func_publish_https(`recordName`: RustBuffer.ByValue,`target`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
954
|
+
): RustBuffer.ByValue
|
|
955
|
+
fun uniffi_pubkycore_fn_func_put(`url`: RustBuffer.ByValue,`content`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
956
|
+
): RustBuffer.ByValue
|
|
957
|
+
fun uniffi_pubkycore_fn_func_remove_event_listener(uniffi_out_err: UniffiRustCallStatus,
|
|
958
|
+
): Unit
|
|
959
|
+
fun uniffi_pubkycore_fn_func_republish_homeserver(`secretKey`: RustBuffer.ByValue,`homeserver`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
960
|
+
): RustBuffer.ByValue
|
|
961
|
+
fun uniffi_pubkycore_fn_func_resolve(`publicKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
962
|
+
): RustBuffer.ByValue
|
|
963
|
+
fun uniffi_pubkycore_fn_func_resolve_https(`publicKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
964
|
+
): RustBuffer.ByValue
|
|
965
|
+
fun uniffi_pubkycore_fn_func_revalidate_session(`sessionSecret`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
966
|
+
): RustBuffer.ByValue
|
|
967
|
+
fun uniffi_pubkycore_fn_func_set_event_listener(`listener`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
968
|
+
): Unit
|
|
969
|
+
fun uniffi_pubkycore_fn_func_sign_in(`secretKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
970
|
+
): RustBuffer.ByValue
|
|
971
|
+
fun uniffi_pubkycore_fn_func_sign_out(`sessionSecret`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
972
|
+
): RustBuffer.ByValue
|
|
973
|
+
fun uniffi_pubkycore_fn_func_sign_up(`secretKey`: RustBuffer.ByValue,`homeserver`: RustBuffer.ByValue,`signupToken`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
974
|
+
): RustBuffer.ByValue
|
|
975
|
+
fun uniffi_pubkycore_fn_func_switch_network(`useTestnet`: Byte,uniffi_out_err: UniffiRustCallStatus,
|
|
976
|
+
): RustBuffer.ByValue
|
|
977
|
+
fun uniffi_pubkycore_fn_func_validate_mnemonic_phrase(`mnemonicPhrase`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
978
|
+
): RustBuffer.ByValue
|
|
979
|
+
fun ffi_pubkycore_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
980
|
+
): RustBuffer.ByValue
|
|
981
|
+
fun ffi_pubkycore_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
982
|
+
): RustBuffer.ByValue
|
|
983
|
+
fun ffi_pubkycore_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
984
|
+
): Unit
|
|
985
|
+
fun ffi_pubkycore_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
986
|
+
): RustBuffer.ByValue
|
|
987
|
+
fun ffi_pubkycore_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
988
|
+
): Unit
|
|
989
|
+
fun ffi_pubkycore_rust_future_cancel_u8(`handle`: Long,
|
|
990
|
+
): Unit
|
|
991
|
+
fun ffi_pubkycore_rust_future_free_u8(`handle`: Long,
|
|
992
|
+
): Unit
|
|
993
|
+
fun ffi_pubkycore_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
994
|
+
): Byte
|
|
995
|
+
fun ffi_pubkycore_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
996
|
+
): Unit
|
|
997
|
+
fun ffi_pubkycore_rust_future_cancel_i8(`handle`: Long,
|
|
998
|
+
): Unit
|
|
999
|
+
fun ffi_pubkycore_rust_future_free_i8(`handle`: Long,
|
|
1000
|
+
): Unit
|
|
1001
|
+
fun ffi_pubkycore_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1002
|
+
): Byte
|
|
1003
|
+
fun ffi_pubkycore_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1004
|
+
): Unit
|
|
1005
|
+
fun ffi_pubkycore_rust_future_cancel_u16(`handle`: Long,
|
|
1006
|
+
): Unit
|
|
1007
|
+
fun ffi_pubkycore_rust_future_free_u16(`handle`: Long,
|
|
1008
|
+
): Unit
|
|
1009
|
+
fun ffi_pubkycore_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1010
|
+
): Short
|
|
1011
|
+
fun ffi_pubkycore_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1012
|
+
): Unit
|
|
1013
|
+
fun ffi_pubkycore_rust_future_cancel_i16(`handle`: Long,
|
|
1014
|
+
): Unit
|
|
1015
|
+
fun ffi_pubkycore_rust_future_free_i16(`handle`: Long,
|
|
1016
|
+
): Unit
|
|
1017
|
+
fun ffi_pubkycore_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1018
|
+
): Short
|
|
1019
|
+
fun ffi_pubkycore_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1020
|
+
): Unit
|
|
1021
|
+
fun ffi_pubkycore_rust_future_cancel_u32(`handle`: Long,
|
|
1022
|
+
): Unit
|
|
1023
|
+
fun ffi_pubkycore_rust_future_free_u32(`handle`: Long,
|
|
1024
|
+
): Unit
|
|
1025
|
+
fun ffi_pubkycore_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1026
|
+
): Int
|
|
1027
|
+
fun ffi_pubkycore_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1028
|
+
): Unit
|
|
1029
|
+
fun ffi_pubkycore_rust_future_cancel_i32(`handle`: Long,
|
|
1030
|
+
): Unit
|
|
1031
|
+
fun ffi_pubkycore_rust_future_free_i32(`handle`: Long,
|
|
1032
|
+
): Unit
|
|
1033
|
+
fun ffi_pubkycore_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1034
|
+
): Int
|
|
1035
|
+
fun ffi_pubkycore_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1036
|
+
): Unit
|
|
1037
|
+
fun ffi_pubkycore_rust_future_cancel_u64(`handle`: Long,
|
|
1038
|
+
): Unit
|
|
1039
|
+
fun ffi_pubkycore_rust_future_free_u64(`handle`: Long,
|
|
1040
|
+
): Unit
|
|
1041
|
+
fun ffi_pubkycore_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1042
|
+
): Long
|
|
1043
|
+
fun ffi_pubkycore_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1044
|
+
): Unit
|
|
1045
|
+
fun ffi_pubkycore_rust_future_cancel_i64(`handle`: Long,
|
|
1046
|
+
): Unit
|
|
1047
|
+
fun ffi_pubkycore_rust_future_free_i64(`handle`: Long,
|
|
1048
|
+
): Unit
|
|
1049
|
+
fun ffi_pubkycore_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1050
|
+
): Long
|
|
1051
|
+
fun ffi_pubkycore_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1052
|
+
): Unit
|
|
1053
|
+
fun ffi_pubkycore_rust_future_cancel_f32(`handle`: Long,
|
|
1054
|
+
): Unit
|
|
1055
|
+
fun ffi_pubkycore_rust_future_free_f32(`handle`: Long,
|
|
1056
|
+
): Unit
|
|
1057
|
+
fun ffi_pubkycore_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1058
|
+
): Float
|
|
1059
|
+
fun ffi_pubkycore_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1060
|
+
): Unit
|
|
1061
|
+
fun ffi_pubkycore_rust_future_cancel_f64(`handle`: Long,
|
|
1062
|
+
): Unit
|
|
1063
|
+
fun ffi_pubkycore_rust_future_free_f64(`handle`: Long,
|
|
1064
|
+
): Unit
|
|
1065
|
+
fun ffi_pubkycore_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1066
|
+
): Double
|
|
1067
|
+
fun ffi_pubkycore_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1068
|
+
): Unit
|
|
1069
|
+
fun ffi_pubkycore_rust_future_cancel_pointer(`handle`: Long,
|
|
1070
|
+
): Unit
|
|
1071
|
+
fun ffi_pubkycore_rust_future_free_pointer(`handle`: Long,
|
|
1072
|
+
): Unit
|
|
1073
|
+
fun ffi_pubkycore_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1074
|
+
): Pointer
|
|
1075
|
+
fun ffi_pubkycore_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1076
|
+
): Unit
|
|
1077
|
+
fun ffi_pubkycore_rust_future_cancel_rust_buffer(`handle`: Long,
|
|
1078
|
+
): Unit
|
|
1079
|
+
fun ffi_pubkycore_rust_future_free_rust_buffer(`handle`: Long,
|
|
1080
|
+
): Unit
|
|
1081
|
+
fun ffi_pubkycore_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1082
|
+
): RustBuffer.ByValue
|
|
1083
|
+
fun ffi_pubkycore_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
|
|
1084
|
+
): Unit
|
|
1085
|
+
fun ffi_pubkycore_rust_future_cancel_void(`handle`: Long,
|
|
1086
|
+
): Unit
|
|
1087
|
+
fun ffi_pubkycore_rust_future_free_void(`handle`: Long,
|
|
1088
|
+
): Unit
|
|
1089
|
+
fun ffi_pubkycore_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
|
|
1090
|
+
): Unit
|
|
1091
|
+
|
|
624
1092
|
}
|
|
625
1093
|
|
|
626
|
-
private fun uniffiCheckContractApiVersion(lib:
|
|
1094
|
+
private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) {
|
|
627
1095
|
// Get the bindings contract version from our ComponentInterface
|
|
628
|
-
val bindings_contract_version =
|
|
1096
|
+
val bindings_contract_version = 29
|
|
629
1097
|
// Get the scaffolding contract version by calling the into the dylib
|
|
630
1098
|
val scaffolding_contract_version = lib.ffi_pubkycore_uniffi_contract_version()
|
|
631
1099
|
if (bindings_contract_version != scaffolding_contract_version) {
|
|
632
1100
|
throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
|
633
1101
|
}
|
|
634
1102
|
}
|
|
635
|
-
|
|
636
1103
|
@Suppress("UNUSED_PARAMETER")
|
|
637
|
-
private fun uniffiCheckApiChecksums(lib:
|
|
638
|
-
if (lib.uniffi_pubkycore_checksum_func_auth() !=
|
|
1104
|
+
private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
|
|
1105
|
+
if (lib.uniffi_pubkycore_checksum_func_auth() != 36598.toShort()) {
|
|
639
1106
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
640
1107
|
}
|
|
641
|
-
if (lib.uniffi_pubkycore_checksum_func_create_recovery_file() !=
|
|
1108
|
+
if (lib.uniffi_pubkycore_checksum_func_create_recovery_file() != 13366.toShort()) {
|
|
642
1109
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
643
1110
|
}
|
|
644
|
-
if (lib.uniffi_pubkycore_checksum_func_decrypt_recovery_file() !=
|
|
1111
|
+
if (lib.uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 56578.toShort()) {
|
|
645
1112
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
646
1113
|
}
|
|
647
|
-
if (lib.uniffi_pubkycore_checksum_func_delete_file() !=
|
|
1114
|
+
if (lib.uniffi_pubkycore_checksum_func_delete_file() != 37648.toShort()) {
|
|
648
1115
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
649
1116
|
}
|
|
650
|
-
if (lib.uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() !=
|
|
1117
|
+
if (lib.uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() != 38398.toShort()) {
|
|
651
1118
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
652
1119
|
}
|
|
653
|
-
if (lib.uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() !=
|
|
1120
|
+
if (lib.uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() != 13119.toShort()) {
|
|
654
1121
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
655
1122
|
}
|
|
656
|
-
if (lib.uniffi_pubkycore_checksum_func_generate_secret_key() !=
|
|
1123
|
+
if (lib.uniffi_pubkycore_checksum_func_generate_secret_key() != 63319.toShort()) {
|
|
657
1124
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
658
1125
|
}
|
|
659
|
-
if (lib.uniffi_pubkycore_checksum_func_get() !=
|
|
1126
|
+
if (lib.uniffi_pubkycore_checksum_func_get() != 12463.toShort()) {
|
|
660
1127
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
661
1128
|
}
|
|
662
|
-
if (lib.uniffi_pubkycore_checksum_func_get_homeserver() !=
|
|
1129
|
+
if (lib.uniffi_pubkycore_checksum_func_get_homeserver() != 35947.toShort()) {
|
|
663
1130
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
664
1131
|
}
|
|
665
|
-
if (lib.uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() !=
|
|
1132
|
+
if (lib.uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 65274.toShort()) {
|
|
666
1133
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
667
1134
|
}
|
|
668
|
-
if (lib.uniffi_pubkycore_checksum_func_get_signup_token() !=
|
|
1135
|
+
if (lib.uniffi_pubkycore_checksum_func_get_signup_token() != 7931.toShort()) {
|
|
669
1136
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
670
1137
|
}
|
|
671
|
-
if (lib.uniffi_pubkycore_checksum_func_list() !=
|
|
1138
|
+
if (lib.uniffi_pubkycore_checksum_func_list() != 14351.toShort()) {
|
|
672
1139
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
673
1140
|
}
|
|
674
|
-
if (lib.uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() !=
|
|
1141
|
+
if (lib.uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() != 59088.toShort()) {
|
|
675
1142
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
676
1143
|
}
|
|
677
|
-
if (lib.uniffi_pubkycore_checksum_func_parse_auth_url() !=
|
|
1144
|
+
if (lib.uniffi_pubkycore_checksum_func_parse_auth_url() != 47180.toShort()) {
|
|
678
1145
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
679
1146
|
}
|
|
680
|
-
if (lib.uniffi_pubkycore_checksum_func_publish() !=
|
|
1147
|
+
if (lib.uniffi_pubkycore_checksum_func_publish() != 60897.toShort()) {
|
|
681
1148
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
682
1149
|
}
|
|
683
|
-
if (lib.uniffi_pubkycore_checksum_func_publish_https() !=
|
|
1150
|
+
if (lib.uniffi_pubkycore_checksum_func_publish_https() != 43863.toShort()) {
|
|
684
1151
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
685
1152
|
}
|
|
686
|
-
if (lib.uniffi_pubkycore_checksum_func_put() !=
|
|
1153
|
+
if (lib.uniffi_pubkycore_checksum_func_put() != 29897.toShort()) {
|
|
687
1154
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
688
1155
|
}
|
|
689
|
-
if (lib.uniffi_pubkycore_checksum_func_remove_event_listener() !=
|
|
1156
|
+
if (lib.uniffi_pubkycore_checksum_func_remove_event_listener() != 3828.toShort()) {
|
|
690
1157
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
691
1158
|
}
|
|
692
|
-
if (lib.uniffi_pubkycore_checksum_func_republish_homeserver() !=
|
|
1159
|
+
if (lib.uniffi_pubkycore_checksum_func_republish_homeserver() != 20001.toShort()) {
|
|
693
1160
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
694
1161
|
}
|
|
695
|
-
if (lib.uniffi_pubkycore_checksum_func_resolve() !=
|
|
1162
|
+
if (lib.uniffi_pubkycore_checksum_func_resolve() != 873.toShort()) {
|
|
696
1163
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
697
1164
|
}
|
|
698
|
-
if (lib.uniffi_pubkycore_checksum_func_resolve_https() !=
|
|
1165
|
+
if (lib.uniffi_pubkycore_checksum_func_resolve_https() != 34852.toShort()) {
|
|
699
1166
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
700
1167
|
}
|
|
701
|
-
if (lib.
|
|
1168
|
+
if (lib.uniffi_pubkycore_checksum_func_revalidate_session() != 12593.toShort()) {
|
|
702
1169
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
703
1170
|
}
|
|
704
|
-
if (lib.uniffi_pubkycore_checksum_func_set_event_listener() !=
|
|
1171
|
+
if (lib.uniffi_pubkycore_checksum_func_set_event_listener() != 18894.toShort()) {
|
|
705
1172
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
706
1173
|
}
|
|
707
|
-
if (lib.uniffi_pubkycore_checksum_func_sign_in() !=
|
|
1174
|
+
if (lib.uniffi_pubkycore_checksum_func_sign_in() != 31244.toShort()) {
|
|
708
1175
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
709
1176
|
}
|
|
710
|
-
if (lib.uniffi_pubkycore_checksum_func_sign_out() !=
|
|
1177
|
+
if (lib.uniffi_pubkycore_checksum_func_sign_out() != 9048.toShort()) {
|
|
711
1178
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
712
1179
|
}
|
|
713
|
-
if (lib.uniffi_pubkycore_checksum_func_sign_up() !=
|
|
1180
|
+
if (lib.uniffi_pubkycore_checksum_func_sign_up() != 49409.toShort()) {
|
|
714
1181
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
715
1182
|
}
|
|
716
|
-
if (lib.uniffi_pubkycore_checksum_func_switch_network() !=
|
|
1183
|
+
if (lib.uniffi_pubkycore_checksum_func_switch_network() != 48346.toShort()) {
|
|
717
1184
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
718
1185
|
}
|
|
719
|
-
if (lib.uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() !=
|
|
1186
|
+
if (lib.uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() != 9633.toShort()) {
|
|
720
1187
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
721
1188
|
}
|
|
722
|
-
if (lib.uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() !=
|
|
1189
|
+
if (lib.uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 24359.toShort()) {
|
|
723
1190
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
724
1191
|
}
|
|
725
1192
|
}
|
|
726
1193
|
|
|
727
|
-
|
|
1194
|
+
/**
|
|
1195
|
+
* @suppress
|
|
1196
|
+
*/
|
|
1197
|
+
public fun uniffiEnsureInitialized() {
|
|
1198
|
+
UniffiLib.INSTANCE
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// Async support
|
|
728
1202
|
|
|
729
1203
|
// Public interface members begin here.
|
|
730
1204
|
|
|
731
1205
|
|
|
1206
|
+
// Interface implemented by anything that can contain an object reference.
|
|
1207
|
+
//
|
|
1208
|
+
// Such types expose a `destroy()` method that must be called to cleanly
|
|
1209
|
+
// dispose of the contained objects. Failure to call this method may result
|
|
1210
|
+
// in memory leaks.
|
|
1211
|
+
//
|
|
1212
|
+
// The easiest way to ensure this method is called is to use the `.use`
|
|
1213
|
+
// helper method to execute a block and destroy the object at the end.
|
|
1214
|
+
interface Disposable {
|
|
1215
|
+
fun destroy()
|
|
1216
|
+
companion object {
|
|
1217
|
+
fun destroy(vararg args: Any?) {
|
|
1218
|
+
for (arg in args) {
|
|
1219
|
+
when (arg) {
|
|
1220
|
+
is Disposable -> arg.destroy()
|
|
1221
|
+
is ArrayList<*> -> {
|
|
1222
|
+
for (idx in arg.indices) {
|
|
1223
|
+
val element = arg[idx]
|
|
1224
|
+
if (element is Disposable) {
|
|
1225
|
+
element.destroy()
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
is Map<*, *> -> {
|
|
1230
|
+
for (element in arg.values) {
|
|
1231
|
+
if (element is Disposable) {
|
|
1232
|
+
element.destroy()
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
is Iterable<*> -> {
|
|
1237
|
+
for (element in arg) {
|
|
1238
|
+
if (element is Disposable) {
|
|
1239
|
+
element.destroy()
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* @suppress
|
|
1251
|
+
*/
|
|
1252
|
+
inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
1253
|
+
try {
|
|
1254
|
+
block(this)
|
|
1255
|
+
} finally {
|
|
1256
|
+
try {
|
|
1257
|
+
// N.B. our implementation is on the nullable type `Disposable?`.
|
|
1258
|
+
this?.destroy()
|
|
1259
|
+
} catch (e: Throwable) {
|
|
1260
|
+
// swallow
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.
|
|
1266
|
+
*
|
|
1267
|
+
* @suppress
|
|
1268
|
+
* */
|
|
1269
|
+
object NoPointer// Magic number for the Rust proxy to call using the same mechanism as every other method,
|
|
1270
|
+
// to free the callback once it's dropped by Rust.
|
|
1271
|
+
internal const val IDX_CALLBACK_FREE = 0
|
|
1272
|
+
// Callback return codes
|
|
1273
|
+
internal const val UNIFFI_CALLBACK_SUCCESS = 0
|
|
1274
|
+
internal const val UNIFFI_CALLBACK_ERROR = 1
|
|
1275
|
+
internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* @suppress
|
|
1279
|
+
*/
|
|
1280
|
+
public abstract class FfiConverterCallbackInterface<CallbackInterface: Any>: FfiConverter<CallbackInterface, Long> {
|
|
1281
|
+
internal val handleMap = UniffiHandleMap<CallbackInterface>()
|
|
1282
|
+
|
|
1283
|
+
internal fun drop(handle: Long) {
|
|
1284
|
+
handleMap.remove(handle)
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
override fun lift(value: Long): CallbackInterface {
|
|
1288
|
+
return handleMap.get(value)
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
override fun read(buf: ByteBuffer) = lift(buf.getLong())
|
|
1292
|
+
|
|
1293
|
+
override fun lower(value: CallbackInterface) = handleMap.insert(value)
|
|
1294
|
+
|
|
1295
|
+
override fun allocationSize(value: CallbackInterface) = 8UL
|
|
1296
|
+
|
|
1297
|
+
override fun write(value: CallbackInterface, buf: ByteBuffer) {
|
|
1298
|
+
buf.putLong(lower(value))
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* The cleaner interface for Object finalization code to run.
|
|
1303
|
+
* This is the entry point to any implementation that we're using.
|
|
1304
|
+
*
|
|
1305
|
+
* The cleaner registers objects and returns cleanables, so now we are
|
|
1306
|
+
* defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the
|
|
1307
|
+
* different implmentations available at compile time.
|
|
1308
|
+
*
|
|
1309
|
+
* @suppress
|
|
1310
|
+
*/
|
|
1311
|
+
interface UniffiCleaner {
|
|
1312
|
+
interface Cleanable {
|
|
1313
|
+
fun clean()
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable
|
|
1317
|
+
|
|
1318
|
+
companion object
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// The fallback Jna cleaner, which is available for both Android, and the JVM.
|
|
1322
|
+
private class UniffiJnaCleaner : UniffiCleaner {
|
|
1323
|
+
private val cleaner = com.sun.jna.internal.Cleaner.getCleaner()
|
|
1324
|
+
|
|
1325
|
+
override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
|
|
1326
|
+
UniffiJnaCleanable(cleaner.register(value, cleanUpTask))
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
private class UniffiJnaCleanable(
|
|
1330
|
+
private val cleanable: com.sun.jna.internal.Cleaner.Cleanable,
|
|
1331
|
+
) : UniffiCleaner.Cleanable {
|
|
1332
|
+
override fun clean() = cleanable.clean()
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
// We decide at uniffi binding generation time whether we were
|
|
1337
|
+
// using Android or not.
|
|
1338
|
+
// There are further runtime checks to chose the correct implementation
|
|
1339
|
+
// of the cleaner.
|
|
1340
|
+
private fun UniffiCleaner.Companion.create(): UniffiCleaner =
|
|
1341
|
+
try {
|
|
1342
|
+
// For safety's sake: if the library hasn't been run in android_cleaner = true
|
|
1343
|
+
// mode, but is being run on Android, then we still need to think about
|
|
1344
|
+
// Android API versions.
|
|
1345
|
+
// So we check if java.lang.ref.Cleaner is there, and use that…
|
|
1346
|
+
java.lang.Class.forName("java.lang.ref.Cleaner")
|
|
1347
|
+
JavaLangRefCleaner()
|
|
1348
|
+
} catch (e: ClassNotFoundException) {
|
|
1349
|
+
// … otherwise, fallback to the JNA cleaner.
|
|
1350
|
+
UniffiJnaCleaner()
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
private class JavaLangRefCleaner : UniffiCleaner {
|
|
1354
|
+
val cleaner = java.lang.ref.Cleaner.create()
|
|
1355
|
+
|
|
1356
|
+
override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
|
|
1357
|
+
JavaLangRefCleanable(cleaner.register(value, cleanUpTask))
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
private class JavaLangRefCleanable(
|
|
1361
|
+
val cleanable: java.lang.ref.Cleaner.Cleanable
|
|
1362
|
+
) : UniffiCleaner.Cleanable {
|
|
1363
|
+
override fun clean() = cleanable.clean()
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* @suppress
|
|
1368
|
+
*/
|
|
732
1369
|
public object FfiConverterBoolean: FfiConverter<Boolean, Byte> {
|
|
733
1370
|
override fun lift(value: Byte): Boolean {
|
|
734
1371
|
return value.toInt() != 0
|
|
@@ -742,20 +1379,23 @@ public object FfiConverterBoolean: FfiConverter<Boolean, Byte> {
|
|
|
742
1379
|
return if (value) 1.toByte() else 0.toByte()
|
|
743
1380
|
}
|
|
744
1381
|
|
|
745
|
-
override fun allocationSize(value: Boolean) =
|
|
1382
|
+
override fun allocationSize(value: Boolean) = 1UL
|
|
746
1383
|
|
|
747
1384
|
override fun write(value: Boolean, buf: ByteBuffer) {
|
|
748
1385
|
buf.put(lower(value))
|
|
749
1386
|
}
|
|
750
1387
|
}
|
|
751
1388
|
|
|
1389
|
+
/**
|
|
1390
|
+
* @suppress
|
|
1391
|
+
*/
|
|
752
1392
|
public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
|
|
753
1393
|
// Note: we don't inherit from FfiConverterRustBuffer, because we use a
|
|
754
1394
|
// special encoding when lowering/lifting. We can use `RustBuffer.len` to
|
|
755
1395
|
// store our length and avoid writing it out to the buffer.
|
|
756
1396
|
override fun lift(value: RustBuffer.ByValue): String {
|
|
757
1397
|
try {
|
|
758
|
-
val byteArr = ByteArray(value.len)
|
|
1398
|
+
val byteArr = ByteArray(value.len.toInt())
|
|
759
1399
|
value.asByteBuffer()!!.get(byteArr)
|
|
760
1400
|
return byteArr.toString(Charsets.UTF_8)
|
|
761
1401
|
} finally {
|
|
@@ -782,7 +1422,7 @@ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
|
|
|
782
1422
|
val byteBuf = toUtf8(value)
|
|
783
1423
|
// Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
|
|
784
1424
|
// to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
|
|
785
|
-
val rbuf = RustBuffer.alloc(byteBuf.limit())
|
|
1425
|
+
val rbuf = RustBuffer.alloc(byteBuf.limit().toULong())
|
|
786
1426
|
rbuf.asByteBuffer()!!.put(byteBuf)
|
|
787
1427
|
return rbuf
|
|
788
1428
|
}
|
|
@@ -790,9 +1430,9 @@ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
|
|
|
790
1430
|
// We aren't sure exactly how many bytes our string will be once it's UTF-8
|
|
791
1431
|
// encoded. Allocate 3 bytes per UTF-16 code unit which will always be
|
|
792
1432
|
// enough.
|
|
793
|
-
override fun allocationSize(value: String):
|
|
794
|
-
val sizeForLength =
|
|
795
|
-
val sizeForString = value.length *
|
|
1433
|
+
override fun allocationSize(value: String): ULong {
|
|
1434
|
+
val sizeForLength = 4UL
|
|
1435
|
+
val sizeForString = value.length.toULong() * 3UL
|
|
796
1436
|
return sizeForLength + sizeForString
|
|
797
1437
|
}
|
|
798
1438
|
|
|
@@ -804,57 +1444,28 @@ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
|
|
|
804
1444
|
}
|
|
805
1445
|
|
|
806
1446
|
|
|
807
|
-
//
|
|
808
|
-
//
|
|
809
|
-
// Such types expose a `destroy()` method that must be called to cleanly
|
|
810
|
-
// dispose of the contained objects. Failure to call this method may result
|
|
811
|
-
// in memory leaks.
|
|
812
|
-
//
|
|
813
|
-
// The easiest way to ensure this method is called is to use the `.use`
|
|
814
|
-
// helper method to execute a block and destroy the object at the end.
|
|
815
|
-
interface Disposable {
|
|
816
|
-
fun destroy()
|
|
817
|
-
companion object {
|
|
818
|
-
fun destroy(vararg args: Any?) {
|
|
819
|
-
args.filterIsInstance<Disposable>()
|
|
820
|
-
.forEach(Disposable::destroy)
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
826
|
-
try {
|
|
827
|
-
block(this)
|
|
828
|
-
} finally {
|
|
829
|
-
try {
|
|
830
|
-
// N.B. our implementation is on the nullable type `Disposable?`.
|
|
831
|
-
this?.destroy()
|
|
832
|
-
} catch (e: Throwable) {
|
|
833
|
-
// swallow
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// The base class for all UniFFI Object types.
|
|
1447
|
+
// This template implements a class for working with a Rust struct via a Pointer/Arc<T>
|
|
1448
|
+
// to the live Rust struct on the other side of the FFI.
|
|
838
1449
|
//
|
|
839
|
-
//
|
|
840
|
-
// the live Rust struct on the other side of the FFI.
|
|
1450
|
+
// Each instance implements core operations for working with the Rust `Arc<T>` and the
|
|
1451
|
+
// Kotlin Pointer to work with the live Rust struct on the other side of the FFI.
|
|
841
1452
|
//
|
|
842
1453
|
// There's some subtlety here, because we have to be careful not to operate on a Rust
|
|
843
1454
|
// struct after it has been dropped, and because we must expose a public API for freeing
|
|
844
|
-
//
|
|
1455
|
+
// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:
|
|
845
1456
|
//
|
|
846
|
-
// * Each
|
|
1457
|
+
// * Each instance holds an opaque pointer to the underlying Rust struct.
|
|
847
1458
|
// Method calls need to read this pointer from the object's state and pass it in to
|
|
848
1459
|
// the Rust FFI.
|
|
849
1460
|
//
|
|
850
|
-
// * When an
|
|
1461
|
+
// * When an instance is no longer needed, its pointer should be passed to a
|
|
851
1462
|
// special destructor function provided by the Rust FFI, which will drop the
|
|
852
1463
|
// underlying Rust struct.
|
|
853
1464
|
//
|
|
854
|
-
// * Given an
|
|
1465
|
+
// * Given an instance, calling code is expected to call the special
|
|
855
1466
|
// `destroy` method in order to free it after use, either by calling it explicitly
|
|
856
|
-
// or by using a higher-level helper like the `use` method. Failing to do so
|
|
857
|
-
//
|
|
1467
|
+
// or by using a higher-level helper like the `use` method. Failing to do so risks
|
|
1468
|
+
// leaking the underlying Rust struct.
|
|
858
1469
|
//
|
|
859
1470
|
// * We can't assume that calling code will do the right thing, and must be prepared
|
|
860
1471
|
// to handle Kotlin method calls executing concurrently with or even after a call to
|
|
@@ -864,6 +1475,14 @@ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
|
864
1475
|
// the destructor has been called, and must never call the destructor more than once.
|
|
865
1476
|
// Doing so may trigger memory unsafety.
|
|
866
1477
|
//
|
|
1478
|
+
// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`
|
|
1479
|
+
// is implemented to call the destructor when the Kotlin object becomes unreachable.
|
|
1480
|
+
// This is done in a background thread. This is not a panacea, and client code should be aware that
|
|
1481
|
+
// 1. the thread may starve if some there are objects that have poorly performing
|
|
1482
|
+
// `drop` methods or do significant work in their `drop` methods.
|
|
1483
|
+
// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,
|
|
1484
|
+
// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).
|
|
1485
|
+
//
|
|
867
1486
|
// If we try to implement this with mutual exclusion on access to the pointer, there is the
|
|
868
1487
|
// possibility of a race between a method call and a concurrent call to `destroy`:
|
|
869
1488
|
//
|
|
@@ -879,7 +1498,7 @@ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
|
879
1498
|
// generate methods with any hidden blocking semantics, and a `destroy` method that might
|
|
880
1499
|
// block if called incorrectly seems to meet that bar.
|
|
881
1500
|
//
|
|
882
|
-
// So, we achieve our goals by giving each
|
|
1501
|
+
// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track
|
|
883
1502
|
// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`
|
|
884
1503
|
// has been called. These are updated according to the following rules:
|
|
885
1504
|
//
|
|
@@ -905,34 +1524,61 @@ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
|
|
|
905
1524
|
// called *and* all in-flight method calls have completed, avoiding violating any of the expectations
|
|
906
1525
|
// of the underlying Rust code.
|
|
907
1526
|
//
|
|
908
|
-
//
|
|
909
|
-
//
|
|
910
|
-
//
|
|
911
|
-
//
|
|
912
|
-
//
|
|
1527
|
+
// This makes a cleaner a better alternative to _not_ calling `destroy()` as
|
|
1528
|
+
// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`
|
|
1529
|
+
// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner
|
|
1530
|
+
// thread may be starved, and the app will leak memory.
|
|
1531
|
+
//
|
|
1532
|
+
// In this case, `destroy`ing manually may be a better solution.
|
|
913
1533
|
//
|
|
914
|
-
//
|
|
1534
|
+
// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects
|
|
1535
|
+
// with Rust peers are reclaimed:
|
|
1536
|
+
//
|
|
1537
|
+
// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:
|
|
1538
|
+
// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:
|
|
1539
|
+
// 3. The memory is reclaimed when the process terminates.
|
|
915
1540
|
//
|
|
916
1541
|
// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219
|
|
917
1542
|
//
|
|
918
|
-
abstract class FFIObject(
|
|
919
|
-
protected val pointer: Pointer
|
|
920
|
-
): Disposable, AutoCloseable {
|
|
921
1543
|
|
|
922
|
-
private val wasDestroyed = AtomicBoolean(false)
|
|
923
|
-
private val callCounter = AtomicLong(1)
|
|
924
1544
|
|
|
925
|
-
|
|
926
|
-
|
|
1545
|
+
public interface EventNotifierInterface {
|
|
1546
|
+
|
|
1547
|
+
companion object
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
open class EventNotifier: Disposable, AutoCloseable, EventNotifierInterface
|
|
1551
|
+
{
|
|
1552
|
+
|
|
1553
|
+
constructor(pointer: Pointer) {
|
|
1554
|
+
this.pointer = pointer
|
|
1555
|
+
this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
|
|
927
1556
|
}
|
|
928
1557
|
|
|
1558
|
+
/**
|
|
1559
|
+
* This constructor can be used to instantiate a fake object. Only used for tests. Any
|
|
1560
|
+
* attempt to actually use an object constructed this way will fail as there is no
|
|
1561
|
+
* connected Rust object.
|
|
1562
|
+
*/
|
|
1563
|
+
@Suppress("UNUSED_PARAMETER")
|
|
1564
|
+
constructor(noPointer: NoPointer) {
|
|
1565
|
+
this.pointer = null
|
|
1566
|
+
this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
protected val pointer: Pointer?
|
|
1570
|
+
protected val cleanable: UniffiCleaner.Cleanable
|
|
1571
|
+
|
|
1572
|
+
private val wasDestroyed = AtomicBoolean(false)
|
|
1573
|
+
private val callCounter = AtomicLong(1)
|
|
1574
|
+
|
|
929
1575
|
override fun destroy() {
|
|
930
1576
|
// Only allow a single call to this method.
|
|
931
1577
|
// TODO: maybe we should log a warning if called more than once?
|
|
932
1578
|
if (this.wasDestroyed.compareAndSet(false, true)) {
|
|
933
1579
|
// This decrement always matches the initial count of 1 given at creation time.
|
|
934
1580
|
if (this.callCounter.decrementAndGet() == 0L) {
|
|
935
|
-
|
|
1581
|
+
cleanable.clean()
|
|
936
1582
|
}
|
|
937
1583
|
}
|
|
938
1584
|
}
|
|
@@ -956,48 +1602,49 @@ abstract class FFIObject(
|
|
|
956
1602
|
} while (! this.callCounter.compareAndSet(c, c + 1L))
|
|
957
1603
|
// Now we can safely do the method call without the pointer being freed concurrently.
|
|
958
1604
|
try {
|
|
959
|
-
return block(this.
|
|
1605
|
+
return block(this.uniffiClonePointer())
|
|
960
1606
|
} finally {
|
|
961
1607
|
// This decrement always matches the increment we performed above.
|
|
962
1608
|
if (this.callCounter.decrementAndGet() == 0L) {
|
|
963
|
-
|
|
1609
|
+
cleanable.clean()
|
|
964
1610
|
}
|
|
965
1611
|
}
|
|
966
1612
|
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
public interface EventNotifierInterface {
|
|
970
|
-
|
|
971
|
-
companion object
|
|
972
|
-
}
|
|
973
1613
|
|
|
974
|
-
class
|
|
975
|
-
|
|
976
|
-
|
|
1614
|
+
// Use a static inner class instead of a closure so as not to accidentally
|
|
1615
|
+
// capture `this` as part of the cleanable's action.
|
|
1616
|
+
private class UniffiCleanAction(private val pointer: Pointer?) : Runnable {
|
|
1617
|
+
override fun run() {
|
|
1618
|
+
pointer?.let { ptr ->
|
|
1619
|
+
uniffiRustCall { status ->
|
|
1620
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_free_eventnotifier(ptr, status)
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
977
1625
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
* It can be called more than once, but once called, interacting with the object
|
|
982
|
-
* causes an `IllegalStateException`.
|
|
983
|
-
*
|
|
984
|
-
* Clients **must** call this method once done with the object, or cause a memory leak.
|
|
985
|
-
*/
|
|
986
|
-
override protected fun freeRustArcPtr() {
|
|
987
|
-
rustCall() { status ->
|
|
988
|
-
_UniFFILib.INSTANCE.uniffi_pubkycore_fn_free_eventnotifier(this.pointer, status)
|
|
1626
|
+
fun uniffiClonePointer(): Pointer {
|
|
1627
|
+
return uniffiRustCall() { status ->
|
|
1628
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_clone_eventnotifier(pointer!!, status)
|
|
989
1629
|
}
|
|
990
1630
|
}
|
|
991
1631
|
|
|
992
1632
|
|
|
993
1633
|
|
|
994
1634
|
|
|
1635
|
+
|
|
995
1636
|
companion object
|
|
996
1637
|
|
|
997
1638
|
}
|
|
998
1639
|
|
|
1640
|
+
/**
|
|
1641
|
+
* @suppress
|
|
1642
|
+
*/
|
|
999
1643
|
public object FfiConverterTypeEventNotifier: FfiConverter<EventNotifier, Pointer> {
|
|
1000
|
-
|
|
1644
|
+
|
|
1645
|
+
override fun lower(value: EventNotifier): Pointer {
|
|
1646
|
+
return value.uniffiClonePointer()
|
|
1647
|
+
}
|
|
1001
1648
|
|
|
1002
1649
|
override fun lift(value: Pointer): EventNotifier {
|
|
1003
1650
|
return EventNotifier(value)
|
|
@@ -1009,7 +1656,7 @@ public object FfiConverterTypeEventNotifier: FfiConverter<EventNotifier, Pointer
|
|
|
1009
1656
|
return lift(Pointer(buf.getLong()))
|
|
1010
1657
|
}
|
|
1011
1658
|
|
|
1012
|
-
override fun allocationSize(value: EventNotifier) =
|
|
1659
|
+
override fun allocationSize(value: EventNotifier) = 8UL
|
|
1013
1660
|
|
|
1014
1661
|
override fun write(value: EventNotifier, buf: ByteBuffer) {
|
|
1015
1662
|
// The Rust code always expects pointers written as 8 bytes,
|
|
@@ -1021,186 +1668,79 @@ public object FfiConverterTypeEventNotifier: FfiConverter<EventNotifier, Pointer
|
|
|
1021
1668
|
|
|
1022
1669
|
|
|
1023
1670
|
|
|
1024
|
-
internal typealias Handle = Long
|
|
1025
|
-
internal class ConcurrentHandleMap<T>(
|
|
1026
|
-
private val leftMap: MutableMap<Handle, T> = mutableMapOf(),
|
|
1027
|
-
private val rightMap: MutableMap<T, Handle> = mutableMapOf()
|
|
1028
|
-
) {
|
|
1029
|
-
private val lock = java.util.concurrent.locks.ReentrantLock()
|
|
1030
|
-
private val currentHandle = AtomicLong(0L)
|
|
1031
|
-
private val stride = 1L
|
|
1032
|
-
|
|
1033
|
-
fun insert(obj: T): Handle =
|
|
1034
|
-
lock.withLock {
|
|
1035
|
-
rightMap[obj] ?:
|
|
1036
|
-
currentHandle.getAndAdd(stride)
|
|
1037
|
-
.also { handle ->
|
|
1038
|
-
leftMap[handle] = obj
|
|
1039
|
-
rightMap[obj] = handle
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
fun get(handle: Handle) = lock.withLock {
|
|
1044
|
-
leftMap[handle]
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
fun delete(handle: Handle) {
|
|
1048
|
-
this.remove(handle)
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
fun remove(handle: Handle): T? =
|
|
1052
|
-
lock.withLock {
|
|
1053
|
-
leftMap.remove(handle)?.let { obj ->
|
|
1054
|
-
rightMap.remove(obj)
|
|
1055
|
-
obj
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
interface ForeignCallback : com.sun.jna.Callback {
|
|
1061
|
-
public fun callback(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// Magic number for the Rust proxy to call using the same mechanism as every other method,
|
|
1065
|
-
// to free the callback once it's dropped by Rust.
|
|
1066
|
-
internal const val IDX_CALLBACK_FREE = 0
|
|
1067
|
-
// Callback return codes
|
|
1068
|
-
internal const val UNIFFI_CALLBACK_SUCCESS = 0
|
|
1069
|
-
internal const val UNIFFI_CALLBACK_ERROR = 1
|
|
1070
|
-
internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2
|
|
1071
|
-
|
|
1072
|
-
public abstract class FfiConverterCallbackInterface<CallbackInterface>(
|
|
1073
|
-
protected val foreignCallback: ForeignCallback
|
|
1074
|
-
): FfiConverter<CallbackInterface, Handle> {
|
|
1075
|
-
private val handleMap = ConcurrentHandleMap<CallbackInterface>()
|
|
1076
|
-
|
|
1077
|
-
// Registers the foreign callback with the Rust side.
|
|
1078
|
-
// This method is generated for each callback interface.
|
|
1079
|
-
internal abstract fun register(lib: _UniFFILib)
|
|
1080
|
-
|
|
1081
|
-
fun drop(handle: Handle): RustBuffer.ByValue {
|
|
1082
|
-
return handleMap.remove(handle).let { RustBuffer.ByValue() }
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
override fun lift(value: Handle): CallbackInterface {
|
|
1086
|
-
return handleMap.get(value) ?: throw InternalException("No callback in handlemap; this is a Uniffi bug")
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
override fun read(buf: ByteBuffer) = lift(buf.getLong())
|
|
1090
|
-
|
|
1091
|
-
override fun lower(value: CallbackInterface) =
|
|
1092
|
-
handleMap.insert(value).also {
|
|
1093
|
-
assert(handleMap.get(it) === value) { "Handle map is not returning the object we just placed there. This is a bug in the HandleMap." }
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
override fun allocationSize(value: CallbackInterface) = 8
|
|
1097
|
-
|
|
1098
|
-
override fun write(value: CallbackInterface, buf: ByteBuffer) {
|
|
1099
|
-
buf.putLong(lower(value))
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
// Declaration and FfiConverters for EventListener Callback Interface
|
|
1104
1671
|
|
|
1105
1672
|
public interface EventListener {
|
|
1106
|
-
|
|
1673
|
+
|
|
1674
|
+
fun `onEventOccurred`(`eventData`: kotlin.String)
|
|
1107
1675
|
|
|
1108
1676
|
companion object
|
|
1109
1677
|
}
|
|
1110
1678
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
1 -> {
|
|
1124
|
-
// Call the method, write to outBuf and return a status code
|
|
1125
|
-
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` for info
|
|
1126
|
-
try {
|
|
1127
|
-
this.`invokeOnEventOccurred`(cb, argsData, argsLen, outBuf)
|
|
1128
|
-
} catch (e: Throwable) {
|
|
1129
|
-
// Unexpected error
|
|
1130
|
-
try {
|
|
1131
|
-
// Try to serialize the error into a string
|
|
1132
|
-
outBuf.setValue(FfiConverterString.lower(e.toString()))
|
|
1133
|
-
} catch (e: Throwable) {
|
|
1134
|
-
// If that fails, then it's time to give up and just return
|
|
1135
|
-
}
|
|
1136
|
-
UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
else -> {
|
|
1141
|
-
// An unexpected error happened.
|
|
1142
|
-
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
|
1143
|
-
try {
|
|
1144
|
-
// Try to serialize the error into a string
|
|
1145
|
-
outBuf.setValue(FfiConverterString.lower("Invalid Callback index"))
|
|
1146
|
-
} catch (e: Throwable) {
|
|
1147
|
-
// If that fails, then it's time to give up and just return
|
|
1148
|
-
}
|
|
1149
|
-
UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
// Put the implementation in an object so we don't pollute the top-level namespace
|
|
1682
|
+
internal object uniffiCallbackInterfaceEventListener {
|
|
1683
|
+
internal object `onEventOccurred`: UniffiCallbackInterfaceEventListenerMethod0 {
|
|
1684
|
+
override fun callback(`uniffiHandle`: Long,`eventData`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) {
|
|
1685
|
+
val uniffiObj = FfiConverterTypeEventListener.handleMap.get(uniffiHandle)
|
|
1686
|
+
val makeCall = { ->
|
|
1687
|
+
uniffiObj.`onEventOccurred`(
|
|
1688
|
+
FfiConverterString.lift(`eventData`),
|
|
1689
|
+
)
|
|
1150
1690
|
}
|
|
1691
|
+
val writeReturn = { _: Unit -> Unit }
|
|
1692
|
+
uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn)
|
|
1151
1693
|
}
|
|
1152
1694
|
}
|
|
1153
1695
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
val argsBuf = argsData.getByteBuffer(0, argsLen.toLong()).also {
|
|
1158
|
-
it.order(ByteOrder.BIG_ENDIAN)
|
|
1696
|
+
internal object uniffiFree: UniffiCallbackInterfaceFree {
|
|
1697
|
+
override fun callback(handle: Long) {
|
|
1698
|
+
FfiConverterTypeEventListener.handleMap.remove(handle)
|
|
1159
1699
|
}
|
|
1160
|
-
fun makeCall() : Int {
|
|
1161
|
-
kotlinCallbackInterface.`onEventOccurred`(
|
|
1162
|
-
FfiConverterString.read(argsBuf)
|
|
1163
|
-
)
|
|
1164
|
-
return UNIFFI_CALLBACK_SUCCESS
|
|
1165
|
-
}
|
|
1166
|
-
fun makeCallAndHandleError() : Int = makeCall()
|
|
1167
|
-
|
|
1168
|
-
return makeCallAndHandleError()
|
|
1169
1700
|
}
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1172
1701
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
)
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1702
|
+
internal var vtable = UniffiVTableCallbackInterfaceEventListener.UniffiByValue(
|
|
1703
|
+
`onEventOccurred`,
|
|
1704
|
+
uniffiFree,
|
|
1705
|
+
)
|
|
1706
|
+
|
|
1707
|
+
// Registers the foreign callback with the Rust side.
|
|
1708
|
+
// This method is generated for each callback interface.
|
|
1709
|
+
internal fun register(lib: UniffiLib) {
|
|
1710
|
+
lib.uniffi_pubkycore_fn_init_callback_vtable_eventlistener(vtable)
|
|
1181
1711
|
}
|
|
1182
1712
|
}
|
|
1183
1713
|
|
|
1714
|
+
/**
|
|
1715
|
+
* The ffiConverter which transforms the Callbacks in to handles to pass to Rust.
|
|
1716
|
+
*
|
|
1717
|
+
* @suppress
|
|
1718
|
+
*/
|
|
1719
|
+
public object FfiConverterTypeEventListener: FfiConverterCallbackInterface<EventListener>()
|
|
1720
|
+
|
|
1184
1721
|
|
|
1185
1722
|
|
|
1186
1723
|
|
|
1187
|
-
|
|
1188
|
-
|
|
1724
|
+
/**
|
|
1725
|
+
* @suppress
|
|
1726
|
+
*/
|
|
1727
|
+
public object FfiConverterOptionalString: FfiConverterRustBuffer<kotlin.String?> {
|
|
1728
|
+
override fun read(buf: ByteBuffer): kotlin.String? {
|
|
1189
1729
|
if (buf.get().toInt() == 0) {
|
|
1190
1730
|
return null
|
|
1191
1731
|
}
|
|
1192
1732
|
return FfiConverterString.read(buf)
|
|
1193
1733
|
}
|
|
1194
1734
|
|
|
1195
|
-
override fun allocationSize(value: String?):
|
|
1735
|
+
override fun allocationSize(value: kotlin.String?): ULong {
|
|
1196
1736
|
if (value == null) {
|
|
1197
|
-
return
|
|
1737
|
+
return 1UL
|
|
1198
1738
|
} else {
|
|
1199
|
-
return
|
|
1739
|
+
return 1UL + FfiConverterString.allocationSize(value)
|
|
1200
1740
|
}
|
|
1201
1741
|
}
|
|
1202
1742
|
|
|
1203
|
-
override fun write(value: String?, buf: ByteBuffer) {
|
|
1743
|
+
override fun write(value: kotlin.String?, buf: ByteBuffer) {
|
|
1204
1744
|
if (value == null) {
|
|
1205
1745
|
buf.put(0)
|
|
1206
1746
|
} else {
|
|
@@ -1213,249 +1753,285 @@ public object FfiConverterOptionalString: FfiConverterRustBuffer<String?> {
|
|
|
1213
1753
|
|
|
1214
1754
|
|
|
1215
1755
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1756
|
+
/**
|
|
1757
|
+
* @suppress
|
|
1758
|
+
*/
|
|
1759
|
+
public object FfiConverterSequenceString: FfiConverterRustBuffer<List<kotlin.String>> {
|
|
1760
|
+
override fun read(buf: ByteBuffer): List<kotlin.String> {
|
|
1218
1761
|
val len = buf.getInt()
|
|
1219
|
-
return List<String>(len) {
|
|
1762
|
+
return List<kotlin.String>(len) {
|
|
1220
1763
|
FfiConverterString.read(buf)
|
|
1221
1764
|
}
|
|
1222
1765
|
}
|
|
1223
1766
|
|
|
1224
|
-
override fun allocationSize(value: List<String>):
|
|
1225
|
-
val sizeForLength =
|
|
1767
|
+
override fun allocationSize(value: List<kotlin.String>): ULong {
|
|
1768
|
+
val sizeForLength = 4UL
|
|
1226
1769
|
val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum()
|
|
1227
1770
|
return sizeForLength + sizeForItems
|
|
1228
1771
|
}
|
|
1229
1772
|
|
|
1230
|
-
override fun write(value: List<String>, buf: ByteBuffer) {
|
|
1773
|
+
override fun write(value: List<kotlin.String>, buf: ByteBuffer) {
|
|
1231
1774
|
buf.putInt(value.size)
|
|
1232
|
-
value.forEach {
|
|
1775
|
+
value.iterator().forEach {
|
|
1233
1776
|
FfiConverterString.write(it, buf)
|
|
1234
1777
|
}
|
|
1235
1778
|
}
|
|
1779
|
+
} fun `auth`(`url`: kotlin.String, `secretKey`: kotlin.String): List<kotlin.String> {
|
|
1780
|
+
return FfiConverterSequenceString.lift(
|
|
1781
|
+
uniffiRustCall() { _status ->
|
|
1782
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_auth(
|
|
1783
|
+
FfiConverterString.lower(`url`),FfiConverterString.lower(`secretKey`),_status)
|
|
1236
1784
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
fun `createRecoveryFile`(`secretKey`: String, `passphrase`: String): List<String> {
|
|
1247
|
-
return FfiConverterSequenceString.lift(
|
|
1248
|
-
rustCall() { _status ->
|
|
1249
|
-
_UniFFILib.INSTANCE.uniffi_pubkycore_fn_func_create_recovery_file(FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`passphrase`),_status)
|
|
1250
|
-
})
|
|
1785
|
+
)
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
fun `createRecoveryFile`(`secretKey`: kotlin.String, `passphrase`: kotlin.String): List<kotlin.String> {
|
|
1789
|
+
return FfiConverterSequenceString.lift(
|
|
1790
|
+
uniffiRustCall() { _status ->
|
|
1791
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_create_recovery_file(
|
|
1792
|
+
FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`passphrase`),_status)
|
|
1251
1793
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1794
|
+
)
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
fun `decryptRecoveryFile`(`recoveryFile`: kotlin.String, `passphrase`: kotlin.String): List<kotlin.String> {
|
|
1798
|
+
return FfiConverterSequenceString.lift(
|
|
1799
|
+
uniffiRustCall() { _status ->
|
|
1800
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_decrypt_recovery_file(
|
|
1801
|
+
FfiConverterString.lower(`recoveryFile`),FfiConverterString.lower(`passphrase`),_status)
|
|
1259
1802
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1803
|
+
)
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
fun `deleteFile`(`url`: kotlin.String, `secretKey`: kotlin.String): List<kotlin.String> {
|
|
1807
|
+
return FfiConverterSequenceString.lift(
|
|
1808
|
+
uniffiRustCall() { _status ->
|
|
1809
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_delete_file(
|
|
1810
|
+
FfiConverterString.lower(`url`),FfiConverterString.lower(`secretKey`),_status)
|
|
1267
1811
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1812
|
+
)
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
fun `generateMnemonicPhrase`(): List<kotlin.String> {
|
|
1816
|
+
return FfiConverterSequenceString.lift(
|
|
1817
|
+
uniffiRustCall() { _status ->
|
|
1818
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_generate_mnemonic_phrase(
|
|
1819
|
+
_status)
|
|
1275
1820
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1821
|
+
)
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
fun `generateMnemonicPhraseAndKeypair`(): List<kotlin.String> {
|
|
1825
|
+
return FfiConverterSequenceString.lift(
|
|
1826
|
+
uniffiRustCall() { _status ->
|
|
1827
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_generate_mnemonic_phrase_and_keypair(
|
|
1828
|
+
_status)
|
|
1283
1829
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1830
|
+
)
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
fun `generateSecretKey`(): List<kotlin.String> {
|
|
1834
|
+
return FfiConverterSequenceString.lift(
|
|
1835
|
+
uniffiRustCall() { _status ->
|
|
1836
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_generate_secret_key(
|
|
1837
|
+
_status)
|
|
1291
1838
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1839
|
+
)
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
fun `get`(`url`: kotlin.String): List<kotlin.String> {
|
|
1843
|
+
return FfiConverterSequenceString.lift(
|
|
1844
|
+
uniffiRustCall() { _status ->
|
|
1845
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_get(
|
|
1846
|
+
FfiConverterString.lower(`url`),_status)
|
|
1299
1847
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1848
|
+
)
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
fun `getHomeserver`(`pubky`: kotlin.String): List<kotlin.String> {
|
|
1852
|
+
return FfiConverterSequenceString.lift(
|
|
1853
|
+
uniffiRustCall() { _status ->
|
|
1854
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_get_homeserver(
|
|
1855
|
+
FfiConverterString.lower(`pubky`),_status)
|
|
1307
1856
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1857
|
+
)
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
fun `getPublicKeyFromSecretKey`(`secretKey`: kotlin.String): List<kotlin.String> {
|
|
1861
|
+
return FfiConverterSequenceString.lift(
|
|
1862
|
+
uniffiRustCall() { _status ->
|
|
1863
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_get_public_key_from_secret_key(
|
|
1864
|
+
FfiConverterString.lower(`secretKey`),_status)
|
|
1315
1865
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1866
|
+
)
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
fun `getSignupToken`(`homeserverPubky`: kotlin.String, `adminPassword`: kotlin.String): List<kotlin.String> {
|
|
1870
|
+
return FfiConverterSequenceString.lift(
|
|
1871
|
+
uniffiRustCall() { _status ->
|
|
1872
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_get_signup_token(
|
|
1873
|
+
FfiConverterString.lower(`homeserverPubky`),FfiConverterString.lower(`adminPassword`),_status)
|
|
1323
1874
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1875
|
+
)
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
fun `list`(`url`: kotlin.String): List<kotlin.String> {
|
|
1879
|
+
return FfiConverterSequenceString.lift(
|
|
1880
|
+
uniffiRustCall() { _status ->
|
|
1881
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_list(
|
|
1882
|
+
FfiConverterString.lower(`url`),_status)
|
|
1331
1883
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1884
|
+
)
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
fun `mnemonicPhraseToKeypair`(`mnemonicPhrase`: kotlin.String): List<kotlin.String> {
|
|
1888
|
+
return FfiConverterSequenceString.lift(
|
|
1889
|
+
uniffiRustCall() { _status ->
|
|
1890
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_mnemonic_phrase_to_keypair(
|
|
1891
|
+
FfiConverterString.lower(`mnemonicPhrase`),_status)
|
|
1339
1892
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1893
|
+
)
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
fun `parseAuthUrl`(`url`: kotlin.String): List<kotlin.String> {
|
|
1897
|
+
return FfiConverterSequenceString.lift(
|
|
1898
|
+
uniffiRustCall() { _status ->
|
|
1899
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_parse_auth_url(
|
|
1900
|
+
FfiConverterString.lower(`url`),_status)
|
|
1347
1901
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1902
|
+
)
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
fun `publish`(`recordName`: kotlin.String, `recordContent`: kotlin.String, `secretKey`: kotlin.String): List<kotlin.String> {
|
|
1906
|
+
return FfiConverterSequenceString.lift(
|
|
1907
|
+
uniffiRustCall() { _status ->
|
|
1908
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_publish(
|
|
1909
|
+
FfiConverterString.lower(`recordName`),FfiConverterString.lower(`recordContent`),FfiConverterString.lower(`secretKey`),_status)
|
|
1355
1910
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1911
|
+
)
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
fun `publishHttps`(`recordName`: kotlin.String, `target`: kotlin.String, `secretKey`: kotlin.String): List<kotlin.String> {
|
|
1915
|
+
return FfiConverterSequenceString.lift(
|
|
1916
|
+
uniffiRustCall() { _status ->
|
|
1917
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_publish_https(
|
|
1918
|
+
FfiConverterString.lower(`recordName`),FfiConverterString.lower(`target`),FfiConverterString.lower(`secretKey`),_status)
|
|
1363
1919
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1920
|
+
)
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
fun `put`(`url`: kotlin.String, `content`: kotlin.String, `secretKey`: kotlin.String): List<kotlin.String> {
|
|
1924
|
+
return FfiConverterSequenceString.lift(
|
|
1925
|
+
uniffiRustCall() { _status ->
|
|
1926
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_put(
|
|
1927
|
+
FfiConverterString.lower(`url`),FfiConverterString.lower(`content`),FfiConverterString.lower(`secretKey`),_status)
|
|
1371
1928
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
fun `removeEventListener`() =
|
|
1929
|
+
)
|
|
1930
|
+
}
|
|
1375
1931
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1932
|
+
fun `removeEventListener`()
|
|
1933
|
+
=
|
|
1934
|
+
uniffiRustCall() { _status ->
|
|
1935
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_remove_event_listener(
|
|
1936
|
+
_status)
|
|
1378
1937
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
})
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
fun `republishHomeserver`(`secretKey`: kotlin.String, `homeserver`: kotlin.String): List<kotlin.String> {
|
|
1941
|
+
return FfiConverterSequenceString.lift(
|
|
1942
|
+
uniffiRustCall() { _status ->
|
|
1943
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_republish_homeserver(
|
|
1944
|
+
FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`homeserver`),_status)
|
|
1387
1945
|
}
|
|
1946
|
+
)
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1388
1949
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1950
|
+
/**
|
|
1951
|
+
* * Resolve a signed packet from a public key
|
|
1952
|
+
* * @param public_key The public key to resolve
|
|
1953
|
+
* * @returns A vector with two elements: the first element is a boolean indicating success or failure,
|
|
1954
|
+
* * and the second element is the response data (either an error message or the resolved signed packet)
|
|
1955
|
+
* *
|
|
1956
|
+
*/ fun `resolve`(`publicKey`: kotlin.String): List<kotlin.String> {
|
|
1957
|
+
return FfiConverterSequenceString.lift(
|
|
1958
|
+
uniffiRustCall() { _status ->
|
|
1959
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_resolve(
|
|
1960
|
+
FfiConverterString.lower(`publicKey`),_status)
|
|
1395
1961
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1962
|
+
)
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
fun `resolveHttps`(`publicKey`: kotlin.String): List<kotlin.String> {
|
|
1966
|
+
return FfiConverterSequenceString.lift(
|
|
1967
|
+
uniffiRustCall() { _status ->
|
|
1968
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_resolve_https(
|
|
1969
|
+
FfiConverterString.lower(`publicKey`),_status)
|
|
1403
1970
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1971
|
+
)
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
fun `revalidateSession`(`sessionSecret`: kotlin.String): List<kotlin.String> {
|
|
1975
|
+
return FfiConverterSequenceString.lift(
|
|
1976
|
+
uniffiRustCall() { _status ->
|
|
1977
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_revalidate_session(
|
|
1978
|
+
FfiConverterString.lower(`sessionSecret`),_status)
|
|
1411
1979
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
fun `setEventListener`(`listener`: EventListener) =
|
|
1980
|
+
)
|
|
1981
|
+
}
|
|
1415
1982
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1983
|
+
fun `setEventListener`(`listener`: EventListener)
|
|
1984
|
+
=
|
|
1985
|
+
uniffiRustCall() { _status ->
|
|
1986
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_set_event_listener(
|
|
1987
|
+
FfiConverterTypeEventListener.lower(`listener`),_status)
|
|
1418
1988
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
})
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
fun `signIn`(`secretKey`: kotlin.String): List<kotlin.String> {
|
|
1992
|
+
return FfiConverterSequenceString.lift(
|
|
1993
|
+
uniffiRustCall() { _status ->
|
|
1994
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_sign_in(
|
|
1995
|
+
FfiConverterString.lower(`secretKey`),_status)
|
|
1427
1996
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1997
|
+
)
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
fun `signOut`(`sessionSecret`: kotlin.String): List<kotlin.String> {
|
|
2001
|
+
return FfiConverterSequenceString.lift(
|
|
2002
|
+
uniffiRustCall() { _status ->
|
|
2003
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_sign_out(
|
|
2004
|
+
FfiConverterString.lower(`sessionSecret`),_status)
|
|
1435
2005
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
2006
|
+
)
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
fun `signUp`(`secretKey`: kotlin.String, `homeserver`: kotlin.String, `signupToken`: kotlin.String?): List<kotlin.String> {
|
|
2010
|
+
return FfiConverterSequenceString.lift(
|
|
2011
|
+
uniffiRustCall() { _status ->
|
|
2012
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_sign_up(
|
|
2013
|
+
FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`homeserver`),FfiConverterOptionalString.lower(`signupToken`),_status)
|
|
1443
2014
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
2015
|
+
)
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
fun `switchNetwork`(`useTestnet`: kotlin.Boolean): List<kotlin.String> {
|
|
2019
|
+
return FfiConverterSequenceString.lift(
|
|
2020
|
+
uniffiRustCall() { _status ->
|
|
2021
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_switch_network(
|
|
2022
|
+
FfiConverterBoolean.lower(`useTestnet`),_status)
|
|
1451
2023
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
2024
|
+
)
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
fun `validateMnemonicPhrase`(`mnemonicPhrase`: kotlin.String): List<kotlin.String> {
|
|
2028
|
+
return FfiConverterSequenceString.lift(
|
|
2029
|
+
uniffiRustCall() { _status ->
|
|
2030
|
+
UniffiLib.INSTANCE.uniffi_pubkycore_fn_func_validate_mnemonic_phrase(
|
|
2031
|
+
FfiConverterString.lower(`mnemonicPhrase`),_status)
|
|
1459
2032
|
}
|
|
2033
|
+
)
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1460
2036
|
|
|
1461
2037
|
|