@synonymdev/react-native-pubky 0.10.6 → 0.11.1
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 +17 -17
- 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/Info.plist +4 -4
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +5 -5
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/libpubkycore.a +0 -0
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +5 -5
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a +0 -0
- package/ios/Pubky.swift +20 -20
- package/ios/pubkycore.swift +358 -347
- 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
package/ios/pubkycore.swift
CHANGED
|
@@ -6,10 +6,10 @@ import Foundation
|
|
|
6
6
|
// might be in a separate module, or it might be compiled inline into
|
|
7
7
|
// this module. This is a bit of light hackery to work with both.
|
|
8
8
|
#if canImport(pubkycoreFFI)
|
|
9
|
-
import pubkycoreFFI
|
|
9
|
+
import pubkycoreFFI
|
|
10
10
|
#endif
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
private extension RustBuffer {
|
|
13
13
|
// Allocate a new buffer, copying the contents of a `UInt8` array.
|
|
14
14
|
init(bytes: [UInt8]) {
|
|
15
15
|
let rbuf = bytes.withUnsafeBufferPointer { ptr in
|
|
@@ -29,7 +29,7 @@ fileprivate extension RustBuffer {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
private extension ForeignBytes {
|
|
33
33
|
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
|
|
34
34
|
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
|
|
35
35
|
}
|
|
@@ -42,7 +42,7 @@ fileprivate extension ForeignBytes {
|
|
|
42
42
|
// Helper classes/extensions that don't change.
|
|
43
43
|
// Someday, this will be in a library of its own.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
private extension Data {
|
|
46
46
|
init(rustBuffer: RustBuffer) {
|
|
47
47
|
// TODO: This copies the buffer. Can we read directly from a
|
|
48
48
|
// Rust buffer?
|
|
@@ -64,15 +64,15 @@ fileprivate extension Data {
|
|
|
64
64
|
//
|
|
65
65
|
// Instead, the read() method and these helper functions input a tuple of data
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
private func createReader(data: Data) -> (data: Data, offset: Data.Index) {
|
|
68
68
|
(data: data, offset: 0)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// Reads an integer at the current offset, in big-endian order, and advances
|
|
72
72
|
// the offset on success. Throws if reading the integer would move the
|
|
73
73
|
// offset past the end of the buffer.
|
|
74
|
-
|
|
75
|
-
let range = reader.offset..<reader.offset + MemoryLayout<T>.size
|
|
74
|
+
private func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
|
|
75
|
+
let range = reader.offset ..< reader.offset + MemoryLayout<T>.size
|
|
76
76
|
guard reader.data.count >= range.upperBound else {
|
|
77
77
|
throw UniffiInternalError.bufferOverflow
|
|
78
78
|
}
|
|
@@ -82,38 +82,38 @@ fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offs
|
|
|
82
82
|
return value as! T
|
|
83
83
|
}
|
|
84
84
|
var value: T = 0
|
|
85
|
-
let _ = withUnsafeMutableBytes(of: &value
|
|
85
|
+
let _ = withUnsafeMutableBytes(of: &value) { reader.data.copyBytes(to: $0, from: range) }
|
|
86
86
|
reader.offset = range.upperBound
|
|
87
87
|
return value.bigEndian
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// Reads an arbitrary number of bytes, to be used to read
|
|
91
91
|
// raw bytes, this is useful when lifting strings
|
|
92
|
-
|
|
93
|
-
let range = reader.offset..<(reader.offset+count)
|
|
92
|
+
private func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> [UInt8] {
|
|
93
|
+
let range = reader.offset ..< (reader.offset + count)
|
|
94
94
|
guard reader.data.count >= range.upperBound else {
|
|
95
95
|
throw UniffiInternalError.bufferOverflow
|
|
96
96
|
}
|
|
97
97
|
var value = [UInt8](repeating: 0, count: count)
|
|
98
|
-
value.withUnsafeMutableBufferPointer
|
|
98
|
+
value.withUnsafeMutableBufferPointer { buffer in
|
|
99
99
|
reader.data.copyBytes(to: buffer, from: range)
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
reader.offset = range.upperBound
|
|
102
102
|
return value
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// Reads a float at the current offset.
|
|
106
|
-
|
|
107
|
-
return Float(bitPattern:
|
|
106
|
+
private func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
|
|
107
|
+
return try Float(bitPattern: readInt(&reader))
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// Reads a float at the current offset.
|
|
111
|
-
|
|
112
|
-
return Double(bitPattern:
|
|
111
|
+
private func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
|
|
112
|
+
return try Double(bitPattern: readInt(&reader))
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// Indicates if the offset has reached the end of the buffer.
|
|
116
|
-
|
|
116
|
+
private func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
|
|
117
117
|
return reader.offset < reader.data.count
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -121,11 +121,11 @@ fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Boo
|
|
|
121
121
|
// struct, but we use standalone functions instead in order to make external
|
|
122
122
|
// types work. See the above discussion on Readers for details.
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
private func createWriter() -> [UInt8] {
|
|
125
125
|
return []
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
private func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
|
|
129
129
|
writer.append(contentsOf: byteArr)
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -133,22 +133,22 @@ fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: S
|
|
|
133
133
|
//
|
|
134
134
|
// Warning: make sure what you are trying to write
|
|
135
135
|
// is in the correct type!
|
|
136
|
-
|
|
136
|
+
private func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
|
|
137
137
|
var value = value.bigEndian
|
|
138
138
|
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
private func writeFloat(_ writer: inout [UInt8], _ value: Float) {
|
|
142
142
|
writeInt(&writer, value.bitPattern)
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
private func writeDouble(_ writer: inout [UInt8], _ value: Double) {
|
|
146
146
|
writeInt(&writer, value.bitPattern)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// Protocol for types that transfer other types across the FFI. This is
|
|
150
150
|
// analogous go the Rust trait of the same name.
|
|
151
|
-
|
|
151
|
+
private protocol FfiConverter {
|
|
152
152
|
associatedtype FfiType
|
|
153
153
|
associatedtype SwiftType
|
|
154
154
|
|
|
@@ -159,7 +159,7 @@ fileprivate protocol FfiConverter {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// Types conforming to `Primitive` pass themselves directly over the FFI.
|
|
162
|
-
|
|
162
|
+
private protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType {}
|
|
163
163
|
|
|
164
164
|
extension FfiConverterPrimitive {
|
|
165
165
|
public static func lift(_ value: FfiType) throws -> SwiftType {
|
|
@@ -173,7 +173,7 @@ extension FfiConverterPrimitive {
|
|
|
173
173
|
|
|
174
174
|
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
|
|
175
175
|
// Used for complex types where it's hard to write a custom lift/lower.
|
|
176
|
-
|
|
176
|
+
private protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
|
|
177
177
|
|
|
178
178
|
extension FfiConverterRustBuffer {
|
|
179
179
|
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
|
|
@@ -187,14 +187,15 @@ extension FfiConverterRustBuffer {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
public static func lower(_ value: SwiftType) -> RustBuffer {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
var writer = createWriter()
|
|
191
|
+
write(value, into: &writer)
|
|
192
|
+
return RustBuffer(bytes: writer)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
+
|
|
195
196
|
// An error type for FFI errors. These errors occur at the UniFFI level, not
|
|
196
197
|
// the library level.
|
|
197
|
-
|
|
198
|
+
private enum UniffiInternalError: LocalizedError {
|
|
198
199
|
case bufferOverflow
|
|
199
200
|
case incompleteData
|
|
200
201
|
case unexpectedOptionalTag
|
|
@@ -205,7 +206,7 @@ fileprivate enum UniffiInternalError: LocalizedError {
|
|
|
205
206
|
case unexpectedStaleHandle
|
|
206
207
|
case rustPanic(_ message: String)
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
var errorDescription: String? {
|
|
209
210
|
switch self {
|
|
210
211
|
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
|
|
211
212
|
case .incompleteData: return "The buffer still has data after lifting its containing value"
|
|
@@ -220,16 +221,16 @@ fileprivate enum UniffiInternalError: LocalizedError {
|
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
private let CALL_SUCCESS: Int8 = 0
|
|
225
|
+
private let CALL_ERROR: Int8 = 1
|
|
226
|
+
private let CALL_PANIC: Int8 = 2
|
|
227
|
+
private let CALL_CANCELLED: Int8 = 3
|
|
227
228
|
|
|
228
|
-
|
|
229
|
+
private extension RustCallStatus {
|
|
229
230
|
init() {
|
|
230
231
|
self.init(
|
|
231
232
|
code: CALL_SUCCESS,
|
|
232
|
-
errorBuf: RustBuffer
|
|
233
|
+
errorBuf: RustBuffer(
|
|
233
234
|
capacity: 0,
|
|
234
235
|
len: 0,
|
|
235
236
|
data: nil
|
|
@@ -244,7 +245,8 @@ private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T
|
|
|
244
245
|
|
|
245
246
|
private func rustCallWithError<T>(
|
|
246
247
|
_ errorHandler: @escaping (RustBuffer) throws -> Error,
|
|
247
|
-
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T
|
|
248
|
+
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T
|
|
249
|
+
) throws -> T {
|
|
248
250
|
try makeRustCall(callback, errorHandler: errorHandler)
|
|
249
251
|
}
|
|
250
252
|
|
|
@@ -253,7 +255,7 @@ private func makeRustCall<T>(
|
|
|
253
255
|
errorHandler: ((RustBuffer) throws -> Error)?
|
|
254
256
|
) throws -> T {
|
|
255
257
|
uniffiEnsureInitialized()
|
|
256
|
-
var callStatus = RustCallStatus
|
|
258
|
+
var callStatus = RustCallStatus()
|
|
257
259
|
let returnedVal = callback(&callStatus)
|
|
258
260
|
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
|
|
259
261
|
return returnedVal
|
|
@@ -264,65 +266,64 @@ private func uniffiCheckCallStatus(
|
|
|
264
266
|
errorHandler: ((RustBuffer) throws -> Error)?
|
|
265
267
|
) throws {
|
|
266
268
|
switch callStatus.code {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
269
|
+
case CALL_SUCCESS:
|
|
270
|
+
return
|
|
271
|
+
|
|
272
|
+
case CALL_ERROR:
|
|
273
|
+
if let errorHandler = errorHandler {
|
|
274
|
+
throw try errorHandler(callStatus.errorBuf)
|
|
275
|
+
} else {
|
|
276
|
+
callStatus.errorBuf.deallocate()
|
|
277
|
+
throw UniffiInternalError.unexpectedRustCallError
|
|
278
|
+
}
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
280
|
+
case CALL_PANIC:
|
|
281
|
+
// When the rust code sees a panic, it tries to construct a RustBuffer
|
|
282
|
+
// with the message. But if that code panics, then it just sends back
|
|
283
|
+
// an empty buffer.
|
|
284
|
+
if callStatus.errorBuf.len > 0 {
|
|
285
|
+
throw try UniffiInternalError.rustPanic(FfiConverterString.lift(callStatus.errorBuf))
|
|
286
|
+
} else {
|
|
287
|
+
callStatus.errorBuf.deallocate()
|
|
288
|
+
throw UniffiInternalError.rustPanic("Rust panic")
|
|
289
|
+
}
|
|
288
290
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
case CALL_CANCELLED:
|
|
292
|
+
throw CancellationError()
|
|
291
293
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
default:
|
|
295
|
+
throw UniffiInternalError.unexpectedRustCallStatusCode
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
// Public interface members begin here.
|
|
298
300
|
|
|
299
|
-
|
|
300
|
-
fileprivate struct FfiConverterBool : FfiConverter {
|
|
301
|
+
private struct FfiConverterBool: FfiConverter {
|
|
301
302
|
typealias FfiType = Int8
|
|
302
303
|
typealias SwiftType = Bool
|
|
303
304
|
|
|
304
|
-
|
|
305
|
+
static func lift(_ value: Int8) throws -> Bool {
|
|
305
306
|
return value != 0
|
|
306
307
|
}
|
|
307
308
|
|
|
308
|
-
|
|
309
|
+
static func lower(_ value: Bool) -> Int8 {
|
|
309
310
|
return value ? 1 : 0
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
|
|
313
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
|
313
314
|
return try lift(readInt(&buf))
|
|
314
315
|
}
|
|
315
316
|
|
|
316
|
-
|
|
317
|
+
static func write(_ value: Bool, into buf: inout [UInt8]) {
|
|
317
318
|
writeInt(&buf, lower(value))
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
|
|
322
|
+
private struct FfiConverterString: FfiConverter {
|
|
322
323
|
typealias SwiftType = String
|
|
323
324
|
typealias FfiType = RustBuffer
|
|
324
325
|
|
|
325
|
-
|
|
326
|
+
static func lift(_ value: RustBuffer) throws -> String {
|
|
326
327
|
defer {
|
|
327
328
|
value.deallocate()
|
|
328
329
|
}
|
|
@@ -333,7 +334,7 @@ fileprivate struct FfiConverterString: FfiConverter {
|
|
|
333
334
|
return String(bytes: bytes, encoding: String.Encoding.utf8)!
|
|
334
335
|
}
|
|
335
336
|
|
|
336
|
-
|
|
337
|
+
static func lower(_ value: String) -> RustBuffer {
|
|
337
338
|
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
|
338
339
|
// The swift string gives us int8_t, we want uint8_t.
|
|
339
340
|
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
|
@@ -344,22 +345,19 @@ fileprivate struct FfiConverterString: FfiConverter {
|
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
347
|
|
|
347
|
-
|
|
348
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
|
348
349
|
let len: Int32 = try readInt(&buf)
|
|
349
|
-
return String(bytes:
|
|
350
|
+
return try String(bytes: readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
|
|
350
351
|
}
|
|
351
352
|
|
|
352
|
-
|
|
353
|
+
static func write(_ value: String, into buf: inout [UInt8]) {
|
|
353
354
|
let len = Int32(value.utf8.count)
|
|
354
355
|
writeInt(&buf, len)
|
|
355
356
|
writeBytes(&buf, value.utf8)
|
|
356
357
|
}
|
|
357
358
|
}
|
|
358
359
|
|
|
359
|
-
|
|
360
|
-
public protocol EventNotifierProtocol {
|
|
361
|
-
|
|
362
|
-
}
|
|
360
|
+
public protocol EventNotifierProtocol {}
|
|
363
361
|
|
|
364
362
|
public class EventNotifier: EventNotifierProtocol {
|
|
365
363
|
fileprivate let pointer: UnsafeMutableRawPointer
|
|
@@ -374,11 +372,6 @@ public class EventNotifier: EventNotifierProtocol {
|
|
|
374
372
|
deinit {
|
|
375
373
|
try! rustCall { uniffi_pubkycore_fn_free_eventnotifier(pointer, $0) }
|
|
376
374
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
375
|
}
|
|
383
376
|
|
|
384
377
|
public struct FfiConverterTypeEventNotifier: FfiConverter {
|
|
@@ -390,7 +383,7 @@ public struct FfiConverterTypeEventNotifier: FfiConverter {
|
|
|
390
383
|
// The Rust code won't compile if a pointer won't fit in a UInt64.
|
|
391
384
|
// We have to go via `UInt` because that's the thing that's the size of a pointer.
|
|
392
385
|
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
|
|
393
|
-
if
|
|
386
|
+
if ptr == nil {
|
|
394
387
|
throw UniffiInternalError.unexpectedNullPointer
|
|
395
388
|
}
|
|
396
389
|
return try lift(ptr!)
|
|
@@ -411,7 +404,6 @@ public struct FfiConverterTypeEventNotifier: FfiConverter {
|
|
|
411
404
|
}
|
|
412
405
|
}
|
|
413
406
|
|
|
414
|
-
|
|
415
407
|
public func FfiConverterTypeEventNotifier_lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
|
416
408
|
return try FfiConverterTypeEventNotifier.lift(pointer)
|
|
417
409
|
}
|
|
@@ -420,16 +412,16 @@ public func FfiConverterTypeEventNotifier_lower(_ value: EventNotifier) -> Unsaf
|
|
|
420
412
|
return FfiConverterTypeEventNotifier.lower(value)
|
|
421
413
|
}
|
|
422
414
|
|
|
423
|
-
|
|
415
|
+
private extension NSLock {
|
|
424
416
|
func withLock<T>(f: () throws -> T) rethrows -> T {
|
|
425
|
-
|
|
417
|
+
lock()
|
|
426
418
|
defer { self.unlock() }
|
|
427
419
|
return try f()
|
|
428
420
|
}
|
|
429
421
|
}
|
|
430
422
|
|
|
431
|
-
|
|
432
|
-
|
|
423
|
+
private typealias UniFFICallbackHandle = UInt64
|
|
424
|
+
private class UniFFICallbackHandleMap<T> {
|
|
433
425
|
private var leftMap: [UniFFICallbackHandle: T] = [:]
|
|
434
426
|
private var counter: [UniFFICallbackHandle: UInt64] = [:]
|
|
435
427
|
private var rightMap: [ObjectIdentifier: UniFFICallbackHandle] = [:]
|
|
@@ -487,61 +479,57 @@ private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
|
|
|
487
479
|
|
|
488
480
|
// Declaration and FfiConverters for EventListener Callback Interface
|
|
489
481
|
|
|
490
|
-
public protocol EventListener
|
|
491
|
-
func onEventOccurred(eventData: String)
|
|
492
|
-
|
|
482
|
+
public protocol EventListener: AnyObject {
|
|
483
|
+
func onEventOccurred(eventData: String)
|
|
493
484
|
}
|
|
494
485
|
|
|
495
486
|
// The ForeignCallback that is passed to Rust.
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
func invokeOnEventOccurred(_ swiftCallbackInterface: EventListener, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
|
|
487
|
+
private let foreignCallbackCallbackInterfaceEventListener: ForeignCallback = { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer<UInt8>, argsLen: Int32, out_buf: UnsafeMutablePointer<RustBuffer>) -> Int32 in
|
|
488
|
+
func invokeOnEventOccurred(_ swiftCallbackInterface: EventListener, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
|
|
501
489
|
var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
|
|
502
490
|
func makeCall() throws -> Int32 {
|
|
503
491
|
try swiftCallbackInterface.onEventOccurred(
|
|
504
|
-
|
|
505
|
-
|
|
492
|
+
eventData: FfiConverterString.read(from: &reader)
|
|
493
|
+
)
|
|
506
494
|
return UNIFFI_CALLBACK_SUCCESS
|
|
507
495
|
}
|
|
508
496
|
return try makeCall()
|
|
509
497
|
}
|
|
510
498
|
|
|
511
|
-
|
|
512
499
|
switch method {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
do {
|
|
527
|
-
return try invokeOnEventOccurred(cb, argsData, argsLen, out_buf)
|
|
528
|
-
} catch let error {
|
|
529
|
-
out_buf.pointee = FfiConverterString.lower(String(describing: error))
|
|
530
|
-
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// This should never happen, because an out of bounds method index won't
|
|
534
|
-
// ever be used. Once we can catch errors, we should return an InternalError.
|
|
535
|
-
// https://github.com/mozilla/uniffi-rs/issues/351
|
|
536
|
-
default:
|
|
537
|
-
// An unexpected error happened.
|
|
538
|
-
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
|
500
|
+
case IDX_CALLBACK_FREE:
|
|
501
|
+
FfiConverterCallbackInterfaceEventListener.drop(handle: handle)
|
|
502
|
+
// Sucessful return
|
|
503
|
+
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
|
504
|
+
return UNIFFI_CALLBACK_SUCCESS
|
|
505
|
+
|
|
506
|
+
case 1:
|
|
507
|
+
let cb: EventListener
|
|
508
|
+
do {
|
|
509
|
+
cb = try FfiConverterCallbackInterfaceEventListener.lift(handle)
|
|
510
|
+
} catch {
|
|
511
|
+
out_buf.pointee = FfiConverterString.lower("EventListener: Invalid handle")
|
|
539
512
|
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
513
|
+
}
|
|
514
|
+
do {
|
|
515
|
+
return try invokeOnEventOccurred(cb, argsData, argsLen, out_buf)
|
|
516
|
+
} catch {
|
|
517
|
+
out_buf.pointee = FfiConverterString.lower(String(describing: error))
|
|
518
|
+
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// This should never happen, because an out of bounds method index won't
|
|
522
|
+
// ever be used. Once we can catch errors, we should return an InternalError.
|
|
523
|
+
// https://github.com/mozilla/uniffi-rs/issues/351
|
|
524
|
+
default:
|
|
525
|
+
// An unexpected error happened.
|
|
526
|
+
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
|
527
|
+
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
|
540
528
|
}
|
|
541
529
|
}
|
|
542
530
|
|
|
543
531
|
// FfiConverter protocol for callback interfaces
|
|
544
|
-
|
|
532
|
+
private enum FfiConverterCallbackInterfaceEventListener {
|
|
545
533
|
private static let initCallbackOnce: () = {
|
|
546
534
|
// Swift ensures this initializer code will once run once, even when accessed by multiple threads.
|
|
547
535
|
try! rustCall { (err: UnsafeMutablePointer<RustCallStatus>) in
|
|
@@ -560,13 +548,13 @@ fileprivate struct FfiConverterCallbackInterfaceEventListener {
|
|
|
560
548
|
private static var handleMap = UniFFICallbackHandleMap<EventListener>()
|
|
561
549
|
}
|
|
562
550
|
|
|
563
|
-
extension FfiConverterCallbackInterfaceEventListener
|
|
551
|
+
extension FfiConverterCallbackInterfaceEventListener: FfiConverter {
|
|
564
552
|
typealias SwiftType = EventListener
|
|
565
553
|
// We can use Handle as the FfiType because it's a typealias to UInt64
|
|
566
554
|
typealias FfiType = UniFFICallbackHandle
|
|
567
555
|
|
|
568
556
|
public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType {
|
|
569
|
-
ensureCallbackinitialized()
|
|
557
|
+
ensureCallbackinitialized()
|
|
570
558
|
guard let callback = handleMap.get(handle: handle) else {
|
|
571
559
|
throw UniffiInternalError.unexpectedStaleHandle
|
|
572
560
|
}
|
|
@@ -574,26 +562,26 @@ extension FfiConverterCallbackInterfaceEventListener : FfiConverter {
|
|
|
574
562
|
}
|
|
575
563
|
|
|
576
564
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
577
|
-
ensureCallbackinitialized()
|
|
565
|
+
ensureCallbackinitialized()
|
|
578
566
|
let handle: UniFFICallbackHandle = try readInt(&buf)
|
|
579
567
|
return try lift(handle)
|
|
580
568
|
}
|
|
581
569
|
|
|
582
570
|
public static func lower(_ v: SwiftType) -> UniFFICallbackHandle {
|
|
583
|
-
ensureCallbackinitialized()
|
|
571
|
+
ensureCallbackinitialized()
|
|
584
572
|
return handleMap.insert(obj: v)
|
|
585
573
|
}
|
|
586
574
|
|
|
587
575
|
public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
|
|
588
|
-
ensureCallbackinitialized()
|
|
576
|
+
ensureCallbackinitialized()
|
|
589
577
|
writeInt(&buf, lower(v))
|
|
590
578
|
}
|
|
591
579
|
}
|
|
592
580
|
|
|
593
|
-
|
|
581
|
+
private struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
594
582
|
typealias SwiftType = String?
|
|
595
583
|
|
|
596
|
-
|
|
584
|
+
static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|
597
585
|
guard let value = value else {
|
|
598
586
|
writeInt(&buf, Int8(0))
|
|
599
587
|
return
|
|
@@ -602,7 +590,7 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
|
602
590
|
FfiConverterString.write(value, into: &buf)
|
|
603
591
|
}
|
|
604
592
|
|
|
605
|
-
|
|
593
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
606
594
|
switch try readInt(&buf) as Int8 {
|
|
607
595
|
case 0: return nil
|
|
608
596
|
case 1: return try FfiConverterString.read(from: &buf)
|
|
@@ -611,10 +599,10 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
|
611
599
|
}
|
|
612
600
|
}
|
|
613
601
|
|
|
614
|
-
|
|
602
|
+
private struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
615
603
|
typealias SwiftType = [String]
|
|
616
604
|
|
|
617
|
-
|
|
605
|
+
static func write(_ value: [String], into buf: inout [UInt8]) {
|
|
618
606
|
let len = Int32(value.count)
|
|
619
607
|
writeInt(&buf, len)
|
|
620
608
|
for item in value {
|
|
@@ -622,274 +610,296 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
|
622
610
|
}
|
|
623
611
|
}
|
|
624
612
|
|
|
625
|
-
|
|
613
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
|
|
626
614
|
let len: Int32 = try readInt(&buf)
|
|
627
615
|
var seq = [String]()
|
|
628
616
|
seq.reserveCapacity(Int(len))
|
|
629
617
|
for _ in 0 ..< len {
|
|
630
|
-
seq.append(
|
|
618
|
+
try seq.append(FfiConverterString.read(from: &buf))
|
|
631
619
|
}
|
|
632
620
|
return seq
|
|
633
621
|
}
|
|
634
622
|
}
|
|
635
623
|
|
|
636
|
-
public func auth(url: String, secretKey: String)
|
|
637
|
-
return try!
|
|
638
|
-
try! rustCall
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
624
|
+
public func auth(url: String, secretKey: String) -> [String] {
|
|
625
|
+
return try! FfiConverterSequenceString.lift(
|
|
626
|
+
try! rustCall {
|
|
627
|
+
uniffi_pubkycore_fn_func_auth(
|
|
628
|
+
FfiConverterString.lower(url),
|
|
629
|
+
FfiConverterString.lower(secretKey), $0
|
|
630
|
+
)
|
|
631
|
+
}
|
|
643
632
|
)
|
|
644
633
|
}
|
|
645
634
|
|
|
646
|
-
public func createRecoveryFile(secretKey: String, passphrase: String)
|
|
647
|
-
return try!
|
|
648
|
-
try! rustCall
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
635
|
+
public func createRecoveryFile(secretKey: String, passphrase: String) -> [String] {
|
|
636
|
+
return try! FfiConverterSequenceString.lift(
|
|
637
|
+
try! rustCall {
|
|
638
|
+
uniffi_pubkycore_fn_func_create_recovery_file(
|
|
639
|
+
FfiConverterString.lower(secretKey),
|
|
640
|
+
FfiConverterString.lower(passphrase), $0
|
|
641
|
+
)
|
|
642
|
+
}
|
|
653
643
|
)
|
|
654
644
|
}
|
|
655
645
|
|
|
656
|
-
public func decryptRecoveryFile(recoveryFile: String, passphrase: String)
|
|
657
|
-
return try!
|
|
658
|
-
try! rustCall
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
646
|
+
public func decryptRecoveryFile(recoveryFile: String, passphrase: String) -> [String] {
|
|
647
|
+
return try! FfiConverterSequenceString.lift(
|
|
648
|
+
try! rustCall {
|
|
649
|
+
uniffi_pubkycore_fn_func_decrypt_recovery_file(
|
|
650
|
+
FfiConverterString.lower(recoveryFile),
|
|
651
|
+
FfiConverterString.lower(passphrase), $0
|
|
652
|
+
)
|
|
653
|
+
}
|
|
663
654
|
)
|
|
664
655
|
}
|
|
665
656
|
|
|
666
|
-
public func deleteFile(url: String)
|
|
667
|
-
return try!
|
|
668
|
-
try! rustCall
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
657
|
+
public func deleteFile(url: String, secretKey: String) -> [String] {
|
|
658
|
+
return try! FfiConverterSequenceString.lift(
|
|
659
|
+
try! rustCall {
|
|
660
|
+
uniffi_pubkycore_fn_func_delete_file(
|
|
661
|
+
FfiConverterString.lower(url),
|
|
662
|
+
FfiConverterString.lower(secretKey), $0
|
|
663
|
+
)
|
|
664
|
+
}
|
|
672
665
|
)
|
|
673
666
|
}
|
|
674
667
|
|
|
675
|
-
public func generateMnemonicPhrase()
|
|
676
|
-
return try!
|
|
677
|
-
try! rustCall
|
|
678
|
-
|
|
679
|
-
}
|
|
668
|
+
public func generateMnemonicPhrase() -> [String] {
|
|
669
|
+
return try! FfiConverterSequenceString.lift(
|
|
670
|
+
try! rustCall {
|
|
671
|
+
uniffi_pubkycore_fn_func_generate_mnemonic_phrase($0)
|
|
672
|
+
}
|
|
680
673
|
)
|
|
681
674
|
}
|
|
682
675
|
|
|
683
|
-
public func generateMnemonicPhraseAndKeypair()
|
|
684
|
-
return try!
|
|
685
|
-
try! rustCall
|
|
686
|
-
|
|
687
|
-
}
|
|
676
|
+
public func generateMnemonicPhraseAndKeypair() -> [String] {
|
|
677
|
+
return try! FfiConverterSequenceString.lift(
|
|
678
|
+
try! rustCall {
|
|
679
|
+
uniffi_pubkycore_fn_func_generate_mnemonic_phrase_and_keypair($0)
|
|
680
|
+
}
|
|
688
681
|
)
|
|
689
682
|
}
|
|
690
683
|
|
|
691
|
-
public func generateSecretKey()
|
|
692
|
-
return try!
|
|
693
|
-
try! rustCall
|
|
694
|
-
|
|
695
|
-
}
|
|
684
|
+
public func generateSecretKey() -> [String] {
|
|
685
|
+
return try! FfiConverterSequenceString.lift(
|
|
686
|
+
try! rustCall {
|
|
687
|
+
uniffi_pubkycore_fn_func_generate_secret_key($0)
|
|
688
|
+
}
|
|
696
689
|
)
|
|
697
690
|
}
|
|
698
691
|
|
|
699
|
-
public func get(url: String)
|
|
700
|
-
return try!
|
|
701
|
-
try! rustCall
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
692
|
+
public func get(url: String) -> [String] {
|
|
693
|
+
return try! FfiConverterSequenceString.lift(
|
|
694
|
+
try! rustCall {
|
|
695
|
+
uniffi_pubkycore_fn_func_get(
|
|
696
|
+
FfiConverterString.lower(url), $0
|
|
697
|
+
)
|
|
698
|
+
}
|
|
705
699
|
)
|
|
706
700
|
}
|
|
707
701
|
|
|
708
|
-
public func getHomeserver(pubky: String)
|
|
709
|
-
return try!
|
|
710
|
-
try! rustCall
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
702
|
+
public func getHomeserver(pubky: String) -> [String] {
|
|
703
|
+
return try! FfiConverterSequenceString.lift(
|
|
704
|
+
try! rustCall {
|
|
705
|
+
uniffi_pubkycore_fn_func_get_homeserver(
|
|
706
|
+
FfiConverterString.lower(pubky), $0
|
|
707
|
+
)
|
|
708
|
+
}
|
|
714
709
|
)
|
|
715
710
|
}
|
|
716
711
|
|
|
717
|
-
public func getPublicKeyFromSecretKey(secretKey: String)
|
|
718
|
-
return try!
|
|
719
|
-
try! rustCall
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
712
|
+
public func getPublicKeyFromSecretKey(secretKey: String) -> [String] {
|
|
713
|
+
return try! FfiConverterSequenceString.lift(
|
|
714
|
+
try! rustCall {
|
|
715
|
+
uniffi_pubkycore_fn_func_get_public_key_from_secret_key(
|
|
716
|
+
FfiConverterString.lower(secretKey), $0
|
|
717
|
+
)
|
|
718
|
+
}
|
|
723
719
|
)
|
|
724
720
|
}
|
|
725
721
|
|
|
726
|
-
public func getSignupToken(homeserverPubky: String, adminPassword: String)
|
|
727
|
-
return try!
|
|
728
|
-
try! rustCall
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
722
|
+
public func getSignupToken(homeserverPubky: String, adminPassword: String) -> [String] {
|
|
723
|
+
return try! FfiConverterSequenceString.lift(
|
|
724
|
+
try! rustCall {
|
|
725
|
+
uniffi_pubkycore_fn_func_get_signup_token(
|
|
726
|
+
FfiConverterString.lower(homeserverPubky),
|
|
727
|
+
FfiConverterString.lower(adminPassword), $0
|
|
728
|
+
)
|
|
729
|
+
}
|
|
733
730
|
)
|
|
734
731
|
}
|
|
735
732
|
|
|
736
|
-
public func list(url: String)
|
|
737
|
-
return try!
|
|
738
|
-
try! rustCall
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
733
|
+
public func list(url: String) -> [String] {
|
|
734
|
+
return try! FfiConverterSequenceString.lift(
|
|
735
|
+
try! rustCall {
|
|
736
|
+
uniffi_pubkycore_fn_func_list(
|
|
737
|
+
FfiConverterString.lower(url), $0
|
|
738
|
+
)
|
|
739
|
+
}
|
|
742
740
|
)
|
|
743
741
|
}
|
|
744
742
|
|
|
745
|
-
public func mnemonicPhraseToKeypair(mnemonicPhrase: String)
|
|
746
|
-
return try!
|
|
747
|
-
try! rustCall
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
743
|
+
public func mnemonicPhraseToKeypair(mnemonicPhrase: String) -> [String] {
|
|
744
|
+
return try! FfiConverterSequenceString.lift(
|
|
745
|
+
try! rustCall {
|
|
746
|
+
uniffi_pubkycore_fn_func_mnemonic_phrase_to_keypair(
|
|
747
|
+
FfiConverterString.lower(mnemonicPhrase), $0
|
|
748
|
+
)
|
|
749
|
+
}
|
|
751
750
|
)
|
|
752
751
|
}
|
|
753
752
|
|
|
754
|
-
public func parseAuthUrl(url: String)
|
|
755
|
-
return try!
|
|
756
|
-
try! rustCall
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
753
|
+
public func parseAuthUrl(url: String) -> [String] {
|
|
754
|
+
return try! FfiConverterSequenceString.lift(
|
|
755
|
+
try! rustCall {
|
|
756
|
+
uniffi_pubkycore_fn_func_parse_auth_url(
|
|
757
|
+
FfiConverterString.lower(url), $0
|
|
758
|
+
)
|
|
759
|
+
}
|
|
760
760
|
)
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
-
public func publish(recordName: String, recordContent: String, secretKey: String)
|
|
764
|
-
return try!
|
|
765
|
-
try! rustCall
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
763
|
+
public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
|
|
764
|
+
return try! FfiConverterSequenceString.lift(
|
|
765
|
+
try! rustCall {
|
|
766
|
+
uniffi_pubkycore_fn_func_publish(
|
|
767
|
+
FfiConverterString.lower(recordName),
|
|
768
|
+
FfiConverterString.lower(recordContent),
|
|
769
|
+
FfiConverterString.lower(secretKey), $0
|
|
770
|
+
)
|
|
771
|
+
}
|
|
771
772
|
)
|
|
772
773
|
}
|
|
773
774
|
|
|
774
|
-
public func publishHttps(recordName: String, target: String, secretKey: String)
|
|
775
|
-
return try!
|
|
776
|
-
try! rustCall
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
775
|
+
public func publishHttps(recordName: String, target: String, secretKey: String) -> [String] {
|
|
776
|
+
return try! FfiConverterSequenceString.lift(
|
|
777
|
+
try! rustCall {
|
|
778
|
+
uniffi_pubkycore_fn_func_publish_https(
|
|
779
|
+
FfiConverterString.lower(recordName),
|
|
780
|
+
FfiConverterString.lower(target),
|
|
781
|
+
FfiConverterString.lower(secretKey), $0
|
|
782
|
+
)
|
|
783
|
+
}
|
|
782
784
|
)
|
|
783
785
|
}
|
|
784
786
|
|
|
785
|
-
public func put(url: String, content: String)
|
|
786
|
-
return try!
|
|
787
|
-
try! rustCall
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
787
|
+
public func put(url: String, content: String, secretKey: String) -> [String] {
|
|
788
|
+
return try! FfiConverterSequenceString.lift(
|
|
789
|
+
try! rustCall {
|
|
790
|
+
uniffi_pubkycore_fn_func_put(
|
|
791
|
+
FfiConverterString.lower(url),
|
|
792
|
+
FfiConverterString.lower(content),
|
|
793
|
+
FfiConverterString.lower(secretKey), $0
|
|
794
|
+
)
|
|
795
|
+
}
|
|
792
796
|
)
|
|
793
797
|
}
|
|
794
798
|
|
|
795
|
-
public func removeEventListener()
|
|
796
|
-
try! rustCall
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
+
public func removeEventListener() {
|
|
800
|
+
try! rustCall {
|
|
801
|
+
uniffi_pubkycore_fn_func_remove_event_listener($0)
|
|
802
|
+
}
|
|
799
803
|
}
|
|
800
804
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
805
|
+
public func republishHomeserver(secretKey: String, homeserver: String) -> [String] {
|
|
806
|
+
return try! FfiConverterSequenceString.lift(
|
|
807
|
+
try! rustCall {
|
|
808
|
+
uniffi_pubkycore_fn_func_republish_homeserver(
|
|
809
|
+
FfiConverterString.lower(secretKey),
|
|
810
|
+
FfiConverterString.lower(homeserver), $0
|
|
811
|
+
)
|
|
812
|
+
}
|
|
810
813
|
)
|
|
811
814
|
}
|
|
812
815
|
|
|
813
|
-
public func resolve(publicKey: String)
|
|
814
|
-
return try!
|
|
815
|
-
try! rustCall
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
816
|
+
public func resolve(publicKey: String) -> [String] {
|
|
817
|
+
return try! FfiConverterSequenceString.lift(
|
|
818
|
+
try! rustCall {
|
|
819
|
+
uniffi_pubkycore_fn_func_resolve(
|
|
820
|
+
FfiConverterString.lower(publicKey), $0
|
|
821
|
+
)
|
|
822
|
+
}
|
|
819
823
|
)
|
|
820
824
|
}
|
|
821
825
|
|
|
822
|
-
public func resolveHttps(publicKey: String)
|
|
823
|
-
return try!
|
|
824
|
-
try! rustCall
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
826
|
+
public func resolveHttps(publicKey: String) -> [String] {
|
|
827
|
+
return try! FfiConverterSequenceString.lift(
|
|
828
|
+
try! rustCall {
|
|
829
|
+
uniffi_pubkycore_fn_func_resolve_https(
|
|
830
|
+
FfiConverterString.lower(publicKey), $0
|
|
831
|
+
)
|
|
832
|
+
}
|
|
828
833
|
)
|
|
829
834
|
}
|
|
830
835
|
|
|
831
|
-
public func
|
|
832
|
-
return try!
|
|
833
|
-
try! rustCall
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
836
|
+
public func revalidateSession(sessionSecret: String) -> [String] {
|
|
837
|
+
return try! FfiConverterSequenceString.lift(
|
|
838
|
+
try! rustCall {
|
|
839
|
+
uniffi_pubkycore_fn_func_revalidate_session(
|
|
840
|
+
FfiConverterString.lower(sessionSecret), $0
|
|
841
|
+
)
|
|
842
|
+
}
|
|
837
843
|
)
|
|
838
844
|
}
|
|
839
845
|
|
|
840
|
-
public func setEventListener(listener: EventListener)
|
|
841
|
-
try! rustCall
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
846
|
+
public func setEventListener(listener: EventListener) {
|
|
847
|
+
try! rustCall {
|
|
848
|
+
uniffi_pubkycore_fn_func_set_event_listener(
|
|
849
|
+
FfiConverterCallbackInterfaceEventListener.lower(listener), $0
|
|
850
|
+
)
|
|
851
|
+
}
|
|
845
852
|
}
|
|
846
853
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
854
|
+
public func signIn(secretKey: String) -> [String] {
|
|
855
|
+
return try! FfiConverterSequenceString.lift(
|
|
856
|
+
try! rustCall {
|
|
857
|
+
uniffi_pubkycore_fn_func_sign_in(
|
|
858
|
+
FfiConverterString.lower(secretKey), $0
|
|
859
|
+
)
|
|
860
|
+
}
|
|
855
861
|
)
|
|
856
862
|
}
|
|
857
863
|
|
|
858
|
-
public func signOut(
|
|
859
|
-
return try!
|
|
860
|
-
try! rustCall
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
+
public func signOut(sessionSecret: String) -> [String] {
|
|
865
|
+
return try! FfiConverterSequenceString.lift(
|
|
866
|
+
try! rustCall {
|
|
867
|
+
uniffi_pubkycore_fn_func_sign_out(
|
|
868
|
+
FfiConverterString.lower(sessionSecret), $0
|
|
869
|
+
)
|
|
870
|
+
}
|
|
864
871
|
)
|
|
865
872
|
}
|
|
866
873
|
|
|
867
|
-
public func signUp(secretKey: String, homeserver: String, signupToken: String?)
|
|
868
|
-
return try!
|
|
869
|
-
try! rustCall
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
874
|
+
public func signUp(secretKey: String, homeserver: String, signupToken: String?) -> [String] {
|
|
875
|
+
return try! FfiConverterSequenceString.lift(
|
|
876
|
+
try! rustCall {
|
|
877
|
+
uniffi_pubkycore_fn_func_sign_up(
|
|
878
|
+
FfiConverterString.lower(secretKey),
|
|
879
|
+
FfiConverterString.lower(homeserver),
|
|
880
|
+
FfiConverterOptionString.lower(signupToken), $0
|
|
881
|
+
)
|
|
882
|
+
}
|
|
875
883
|
)
|
|
876
884
|
}
|
|
877
885
|
|
|
878
|
-
public func switchNetwork(useTestnet: Bool)
|
|
879
|
-
return try!
|
|
880
|
-
try! rustCall
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
886
|
+
public func switchNetwork(useTestnet: Bool) -> [String] {
|
|
887
|
+
return try! FfiConverterSequenceString.lift(
|
|
888
|
+
try! rustCall {
|
|
889
|
+
uniffi_pubkycore_fn_func_switch_network(
|
|
890
|
+
FfiConverterBool.lower(useTestnet), $0
|
|
891
|
+
)
|
|
892
|
+
}
|
|
884
893
|
)
|
|
885
894
|
}
|
|
886
895
|
|
|
887
|
-
public func validateMnemonicPhrase(mnemonicPhrase: String)
|
|
888
|
-
return try!
|
|
889
|
-
try! rustCall
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
896
|
+
public func validateMnemonicPhrase(mnemonicPhrase: String) -> [String] {
|
|
897
|
+
return try! FfiConverterSequenceString.lift(
|
|
898
|
+
try! rustCall {
|
|
899
|
+
uniffi_pubkycore_fn_func_validate_mnemonic_phrase(
|
|
900
|
+
FfiConverterString.lower(mnemonicPhrase), $0
|
|
901
|
+
)
|
|
902
|
+
}
|
|
893
903
|
)
|
|
894
904
|
}
|
|
895
905
|
|
|
@@ -898,6 +908,7 @@ private enum InitializationResult {
|
|
|
898
908
|
case contractVersionMismatch
|
|
899
909
|
case apiChecksumMismatch
|
|
900
910
|
}
|
|
911
|
+
|
|
901
912
|
// Use a global variables to perform the versioning checks. Swift ensures that
|
|
902
913
|
// the code inside is only computed once.
|
|
903
914
|
private var initializationResult: InitializationResult {
|
|
@@ -908,91 +919,91 @@ private var initializationResult: InitializationResult {
|
|
|
908
919
|
if bindings_contract_version != scaffolding_contract_version {
|
|
909
920
|
return InitializationResult.contractVersionMismatch
|
|
910
921
|
}
|
|
911
|
-
if
|
|
922
|
+
if uniffi_pubkycore_checksum_func_auth() != 51826 {
|
|
912
923
|
return InitializationResult.apiChecksumMismatch
|
|
913
924
|
}
|
|
914
|
-
if
|
|
925
|
+
if uniffi_pubkycore_checksum_func_create_recovery_file() != 48846 {
|
|
915
926
|
return InitializationResult.apiChecksumMismatch
|
|
916
927
|
}
|
|
917
|
-
if
|
|
928
|
+
if uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 26407 {
|
|
918
929
|
return InitializationResult.apiChecksumMismatch
|
|
919
930
|
}
|
|
920
|
-
if
|
|
931
|
+
if uniffi_pubkycore_checksum_func_delete_file() != 47931 {
|
|
921
932
|
return InitializationResult.apiChecksumMismatch
|
|
922
933
|
}
|
|
923
|
-
if
|
|
934
|
+
if uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() != 2358 {
|
|
924
935
|
return InitializationResult.apiChecksumMismatch
|
|
925
936
|
}
|
|
926
|
-
if
|
|
937
|
+
if uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() != 44395 {
|
|
927
938
|
return InitializationResult.apiChecksumMismatch
|
|
928
939
|
}
|
|
929
|
-
if
|
|
940
|
+
if uniffi_pubkycore_checksum_func_generate_secret_key() != 12800 {
|
|
930
941
|
return InitializationResult.apiChecksumMismatch
|
|
931
942
|
}
|
|
932
|
-
if
|
|
943
|
+
if uniffi_pubkycore_checksum_func_get() != 6591 {
|
|
933
944
|
return InitializationResult.apiChecksumMismatch
|
|
934
945
|
}
|
|
935
|
-
if
|
|
946
|
+
if uniffi_pubkycore_checksum_func_get_homeserver() != 40658 {
|
|
936
947
|
return InitializationResult.apiChecksumMismatch
|
|
937
948
|
}
|
|
938
|
-
if
|
|
949
|
+
if uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 40316 {
|
|
939
950
|
return InitializationResult.apiChecksumMismatch
|
|
940
951
|
}
|
|
941
|
-
if
|
|
952
|
+
if uniffi_pubkycore_checksum_func_get_signup_token() != 47927 {
|
|
942
953
|
return InitializationResult.apiChecksumMismatch
|
|
943
954
|
}
|
|
944
|
-
if
|
|
955
|
+
if uniffi_pubkycore_checksum_func_list() != 43198 {
|
|
945
956
|
return InitializationResult.apiChecksumMismatch
|
|
946
957
|
}
|
|
947
|
-
if
|
|
958
|
+
if uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() != 45784 {
|
|
948
959
|
return InitializationResult.apiChecksumMismatch
|
|
949
960
|
}
|
|
950
|
-
if
|
|
961
|
+
if uniffi_pubkycore_checksum_func_parse_auth_url() != 27379 {
|
|
951
962
|
return InitializationResult.apiChecksumMismatch
|
|
952
963
|
}
|
|
953
|
-
if
|
|
964
|
+
if uniffi_pubkycore_checksum_func_publish() != 48989 {
|
|
954
965
|
return InitializationResult.apiChecksumMismatch
|
|
955
966
|
}
|
|
956
|
-
if
|
|
967
|
+
if uniffi_pubkycore_checksum_func_publish_https() != 5614 {
|
|
957
968
|
return InitializationResult.apiChecksumMismatch
|
|
958
969
|
}
|
|
959
|
-
if
|
|
970
|
+
if uniffi_pubkycore_checksum_func_put() != 64514 {
|
|
960
971
|
return InitializationResult.apiChecksumMismatch
|
|
961
972
|
}
|
|
962
|
-
if
|
|
973
|
+
if uniffi_pubkycore_checksum_func_remove_event_listener() != 23534 {
|
|
963
974
|
return InitializationResult.apiChecksumMismatch
|
|
964
975
|
}
|
|
965
|
-
if
|
|
976
|
+
if uniffi_pubkycore_checksum_func_republish_homeserver() != 63919 {
|
|
966
977
|
return InitializationResult.apiChecksumMismatch
|
|
967
978
|
}
|
|
968
|
-
if
|
|
979
|
+
if uniffi_pubkycore_checksum_func_resolve() != 34317 {
|
|
969
980
|
return InitializationResult.apiChecksumMismatch
|
|
970
981
|
}
|
|
971
|
-
if
|
|
982
|
+
if uniffi_pubkycore_checksum_func_resolve_https() != 17266 {
|
|
972
983
|
return InitializationResult.apiChecksumMismatch
|
|
973
984
|
}
|
|
974
|
-
if (
|
|
985
|
+
if uniffi_pubkycore_checksum_func_revalidate_session() != 57726 {
|
|
975
986
|
return InitializationResult.apiChecksumMismatch
|
|
976
987
|
}
|
|
977
|
-
if
|
|
988
|
+
if uniffi_pubkycore_checksum_func_set_event_listener() != 60071 {
|
|
978
989
|
return InitializationResult.apiChecksumMismatch
|
|
979
990
|
}
|
|
980
|
-
if
|
|
991
|
+
if uniffi_pubkycore_checksum_func_sign_in() != 21584 {
|
|
981
992
|
return InitializationResult.apiChecksumMismatch
|
|
982
993
|
}
|
|
983
|
-
if
|
|
994
|
+
if uniffi_pubkycore_checksum_func_sign_out() != 27163 {
|
|
984
995
|
return InitializationResult.apiChecksumMismatch
|
|
985
996
|
}
|
|
986
|
-
if
|
|
997
|
+
if uniffi_pubkycore_checksum_func_sign_up() != 48789 {
|
|
987
998
|
return InitializationResult.apiChecksumMismatch
|
|
988
999
|
}
|
|
989
|
-
if
|
|
1000
|
+
if uniffi_pubkycore_checksum_func_switch_network() != 64215 {
|
|
990
1001
|
return InitializationResult.apiChecksumMismatch
|
|
991
1002
|
}
|
|
992
|
-
if
|
|
1003
|
+
if uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() != 30362 {
|
|
993
1004
|
return InitializationResult.apiChecksumMismatch
|
|
994
1005
|
}
|
|
995
|
-
if
|
|
1006
|
+
if uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 11531 {
|
|
996
1007
|
return InitializationResult.apiChecksumMismatch
|
|
997
1008
|
}
|
|
998
1009
|
|
|
@@ -1008,4 +1019,4 @@ private func uniffiEnsureInitialized() {
|
|
|
1008
1019
|
case .apiChecksumMismatch:
|
|
1009
1020
|
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1010
1021
|
}
|
|
1011
|
-
}
|
|
1022
|
+
}
|