@synonymdev/react-native-pubky 0.11.0 → 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/src/main/java/uniffi/pubkycore/pubkycore.kt +825 -1401
- 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/module.modulemap +2 -3
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +129 -683
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/libpubkycore.a +0 -0
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/module.modulemap +2 -3
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +129 -683
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a +0 -0
- package/ios/pubkycore.swift +503 -561
- package/package.json +1 -1
package/ios/pubkycore.swift
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
|
2
2
|
// Trust me, you don't want to mess with it!
|
|
3
|
-
|
|
4
|
-
// swiftlint:disable all
|
|
5
3
|
import Foundation
|
|
6
4
|
|
|
7
5
|
// Depending on the consumer's build setup, the low-level FFI code
|
|
8
6
|
// might be in a separate module, or it might be compiled inline into
|
|
9
7
|
// this module. This is a bit of light hackery to work with both.
|
|
10
8
|
#if canImport(pubkycoreFFI)
|
|
11
|
-
import pubkycoreFFI
|
|
9
|
+
import pubkycoreFFI
|
|
12
10
|
#endif
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
private extension RustBuffer {
|
|
15
13
|
// Allocate a new buffer, copying the contents of a `UInt8` array.
|
|
16
14
|
init(bytes: [UInt8]) {
|
|
17
15
|
let rbuf = bytes.withUnsafeBufferPointer { ptr in
|
|
@@ -20,10 +18,6 @@ fileprivate extension RustBuffer {
|
|
|
20
18
|
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
static func empty() -> RustBuffer {
|
|
24
|
-
RustBuffer(capacity: 0, len:0, data: nil)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
|
|
28
22
|
try! rustCall { ffi_pubkycore_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
|
|
29
23
|
}
|
|
@@ -35,7 +29,7 @@ fileprivate extension RustBuffer {
|
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
private extension ForeignBytes {
|
|
39
33
|
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
|
|
40
34
|
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
|
|
41
35
|
}
|
|
@@ -48,13 +42,11 @@ fileprivate extension ForeignBytes {
|
|
|
48
42
|
// Helper classes/extensions that don't change.
|
|
49
43
|
// Someday, this will be in a library of its own.
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
private extension Data {
|
|
52
46
|
init(rustBuffer: RustBuffer) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
deallocator: .none
|
|
57
|
-
)
|
|
47
|
+
// TODO: This copies the buffer. Can we read directly from a
|
|
48
|
+
// Rust buffer?
|
|
49
|
+
self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len))
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
|
|
@@ -72,15 +64,15 @@ fileprivate extension Data {
|
|
|
72
64
|
//
|
|
73
65
|
// Instead, the read() method and these helper functions input a tuple of data
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
private func createReader(data: Data) -> (data: Data, offset: Data.Index) {
|
|
76
68
|
(data: data, offset: 0)
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
// Reads an integer at the current offset, in big-endian order, and advances
|
|
80
72
|
// the offset on success. Throws if reading the integer would move the
|
|
81
73
|
// offset past the end of the buffer.
|
|
82
|
-
|
|
83
|
-
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
|
|
84
76
|
guard reader.data.count >= range.upperBound else {
|
|
85
77
|
throw UniffiInternalError.bufferOverflow
|
|
86
78
|
}
|
|
@@ -90,38 +82,38 @@ fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offs
|
|
|
90
82
|
return value as! T
|
|
91
83
|
}
|
|
92
84
|
var value: T = 0
|
|
93
|
-
let _ = withUnsafeMutableBytes(of: &value
|
|
85
|
+
let _ = withUnsafeMutableBytes(of: &value) { reader.data.copyBytes(to: $0, from: range) }
|
|
94
86
|
reader.offset = range.upperBound
|
|
95
87
|
return value.bigEndian
|
|
96
88
|
}
|
|
97
89
|
|
|
98
90
|
// Reads an arbitrary number of bytes, to be used to read
|
|
99
91
|
// raw bytes, this is useful when lifting strings
|
|
100
|
-
|
|
101
|
-
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)
|
|
102
94
|
guard reader.data.count >= range.upperBound else {
|
|
103
95
|
throw UniffiInternalError.bufferOverflow
|
|
104
96
|
}
|
|
105
97
|
var value = [UInt8](repeating: 0, count: count)
|
|
106
|
-
value.withUnsafeMutableBufferPointer
|
|
98
|
+
value.withUnsafeMutableBufferPointer { buffer in
|
|
107
99
|
reader.data.copyBytes(to: buffer, from: range)
|
|
108
|
-
}
|
|
100
|
+
}
|
|
109
101
|
reader.offset = range.upperBound
|
|
110
102
|
return value
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
// Reads a float at the current offset.
|
|
114
|
-
|
|
115
|
-
return Float(bitPattern:
|
|
106
|
+
private func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
|
|
107
|
+
return try Float(bitPattern: readInt(&reader))
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
// Reads a float at the current offset.
|
|
119
|
-
|
|
120
|
-
return Double(bitPattern:
|
|
111
|
+
private func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
|
|
112
|
+
return try Double(bitPattern: readInt(&reader))
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
// Indicates if the offset has reached the end of the buffer.
|
|
124
|
-
|
|
116
|
+
private func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
|
|
125
117
|
return reader.offset < reader.data.count
|
|
126
118
|
}
|
|
127
119
|
|
|
@@ -129,11 +121,11 @@ fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Boo
|
|
|
129
121
|
// struct, but we use standalone functions instead in order to make external
|
|
130
122
|
// types work. See the above discussion on Readers for details.
|
|
131
123
|
|
|
132
|
-
|
|
124
|
+
private func createWriter() -> [UInt8] {
|
|
133
125
|
return []
|
|
134
126
|
}
|
|
135
127
|
|
|
136
|
-
|
|
128
|
+
private func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
|
|
137
129
|
writer.append(contentsOf: byteArr)
|
|
138
130
|
}
|
|
139
131
|
|
|
@@ -141,22 +133,22 @@ fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: S
|
|
|
141
133
|
//
|
|
142
134
|
// Warning: make sure what you are trying to write
|
|
143
135
|
// is in the correct type!
|
|
144
|
-
|
|
136
|
+
private func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
|
|
145
137
|
var value = value.bigEndian
|
|
146
138
|
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
|
|
147
139
|
}
|
|
148
140
|
|
|
149
|
-
|
|
141
|
+
private func writeFloat(_ writer: inout [UInt8], _ value: Float) {
|
|
150
142
|
writeInt(&writer, value.bitPattern)
|
|
151
143
|
}
|
|
152
144
|
|
|
153
|
-
|
|
145
|
+
private func writeDouble(_ writer: inout [UInt8], _ value: Double) {
|
|
154
146
|
writeInt(&writer, value.bitPattern)
|
|
155
147
|
}
|
|
156
148
|
|
|
157
149
|
// Protocol for types that transfer other types across the FFI. This is
|
|
158
|
-
// analogous
|
|
159
|
-
|
|
150
|
+
// analogous go the Rust trait of the same name.
|
|
151
|
+
private protocol FfiConverter {
|
|
160
152
|
associatedtype FfiType
|
|
161
153
|
associatedtype SwiftType
|
|
162
154
|
|
|
@@ -167,19 +159,13 @@ fileprivate protocol FfiConverter {
|
|
|
167
159
|
}
|
|
168
160
|
|
|
169
161
|
// Types conforming to `Primitive` pass themselves directly over the FFI.
|
|
170
|
-
|
|
162
|
+
private protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType {}
|
|
171
163
|
|
|
172
164
|
extension FfiConverterPrimitive {
|
|
173
|
-
#if swift(>=5.8)
|
|
174
|
-
@_documentation(visibility: private)
|
|
175
|
-
#endif
|
|
176
165
|
public static func lift(_ value: FfiType) throws -> SwiftType {
|
|
177
166
|
return value
|
|
178
167
|
}
|
|
179
168
|
|
|
180
|
-
#if swift(>=5.8)
|
|
181
|
-
@_documentation(visibility: private)
|
|
182
|
-
#endif
|
|
183
169
|
public static func lower(_ value: SwiftType) -> FfiType {
|
|
184
170
|
return value
|
|
185
171
|
}
|
|
@@ -187,12 +173,9 @@ extension FfiConverterPrimitive {
|
|
|
187
173
|
|
|
188
174
|
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
|
|
189
175
|
// Used for complex types where it's hard to write a custom lift/lower.
|
|
190
|
-
|
|
176
|
+
private protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
|
|
191
177
|
|
|
192
178
|
extension FfiConverterRustBuffer {
|
|
193
|
-
#if swift(>=5.8)
|
|
194
|
-
@_documentation(visibility: private)
|
|
195
|
-
#endif
|
|
196
179
|
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
|
|
197
180
|
var reader = createReader(data: Data(rustBuffer: buf))
|
|
198
181
|
let value = try read(from: &reader)
|
|
@@ -203,18 +186,16 @@ extension FfiConverterRustBuffer {
|
|
|
203
186
|
return value
|
|
204
187
|
}
|
|
205
188
|
|
|
206
|
-
#if swift(>=5.8)
|
|
207
|
-
@_documentation(visibility: private)
|
|
208
|
-
#endif
|
|
209
189
|
public static func lower(_ value: SwiftType) -> RustBuffer {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
190
|
+
var writer = createWriter()
|
|
191
|
+
write(value, into: &writer)
|
|
192
|
+
return RustBuffer(bytes: writer)
|
|
213
193
|
}
|
|
214
194
|
}
|
|
195
|
+
|
|
215
196
|
// An error type for FFI errors. These errors occur at the UniFFI level, not
|
|
216
197
|
// the library level.
|
|
217
|
-
|
|
198
|
+
private enum UniffiInternalError: LocalizedError {
|
|
218
199
|
case bufferOverflow
|
|
219
200
|
case incompleteData
|
|
220
201
|
case unexpectedOptionalTag
|
|
@@ -225,7 +206,7 @@ fileprivate enum UniffiInternalError: LocalizedError {
|
|
|
225
206
|
case unexpectedStaleHandle
|
|
226
207
|
case rustPanic(_ message: String)
|
|
227
208
|
|
|
228
|
-
|
|
209
|
+
var errorDescription: String? {
|
|
229
210
|
switch self {
|
|
230
211
|
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
|
|
231
212
|
case .incompleteData: return "The buffer still has data after lifting its containing value"
|
|
@@ -240,24 +221,16 @@ fileprivate enum UniffiInternalError: LocalizedError {
|
|
|
240
221
|
}
|
|
241
222
|
}
|
|
242
223
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return try f()
|
|
248
|
-
}
|
|
249
|
-
}
|
|
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
|
|
250
228
|
|
|
251
|
-
|
|
252
|
-
fileprivate let CALL_ERROR: Int8 = 1
|
|
253
|
-
fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
|
|
254
|
-
fileprivate let CALL_CANCELLED: Int8 = 3
|
|
255
|
-
|
|
256
|
-
fileprivate extension RustCallStatus {
|
|
229
|
+
private extension RustCallStatus {
|
|
257
230
|
init() {
|
|
258
231
|
self.init(
|
|
259
232
|
code: CALL_SUCCESS,
|
|
260
|
-
errorBuf: RustBuffer
|
|
233
|
+
errorBuf: RustBuffer(
|
|
261
234
|
capacity: 0,
|
|
262
235
|
len: 0,
|
|
263
236
|
data: nil
|
|
@@ -267,174 +240,90 @@ fileprivate extension RustCallStatus {
|
|
|
267
240
|
}
|
|
268
241
|
|
|
269
242
|
private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
|
270
|
-
|
|
271
|
-
return try makeRustCall(callback, errorHandler: neverThrow)
|
|
243
|
+
try makeRustCall(callback, errorHandler: nil)
|
|
272
244
|
}
|
|
273
245
|
|
|
274
|
-
private func rustCallWithError<T
|
|
275
|
-
_ errorHandler: @escaping (RustBuffer) throws ->
|
|
276
|
-
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T
|
|
246
|
+
private func rustCallWithError<T>(
|
|
247
|
+
_ errorHandler: @escaping (RustBuffer) throws -> Error,
|
|
248
|
+
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T
|
|
249
|
+
) throws -> T {
|
|
277
250
|
try makeRustCall(callback, errorHandler: errorHandler)
|
|
278
251
|
}
|
|
279
252
|
|
|
280
|
-
private func makeRustCall<T
|
|
253
|
+
private func makeRustCall<T>(
|
|
281
254
|
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
|
|
282
|
-
errorHandler: ((RustBuffer) throws ->
|
|
255
|
+
errorHandler: ((RustBuffer) throws -> Error)?
|
|
283
256
|
) throws -> T {
|
|
284
|
-
|
|
285
|
-
var callStatus = RustCallStatus
|
|
257
|
+
uniffiEnsureInitialized()
|
|
258
|
+
var callStatus = RustCallStatus()
|
|
286
259
|
let returnedVal = callback(&callStatus)
|
|
287
260
|
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
|
|
288
261
|
return returnedVal
|
|
289
262
|
}
|
|
290
263
|
|
|
291
|
-
private func uniffiCheckCallStatus
|
|
264
|
+
private func uniffiCheckCallStatus(
|
|
292
265
|
callStatus: RustCallStatus,
|
|
293
|
-
errorHandler: ((RustBuffer) throws ->
|
|
266
|
+
errorHandler: ((RustBuffer) throws -> Error)?
|
|
294
267
|
) throws {
|
|
295
268
|
switch callStatus.code {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
case CALL_UNEXPECTED_ERROR:
|
|
308
|
-
// When the rust code sees a panic, it tries to construct a RustBuffer
|
|
309
|
-
// with the message. But if that code panics, then it just sends back
|
|
310
|
-
// an empty buffer.
|
|
311
|
-
if callStatus.errorBuf.len > 0 {
|
|
312
|
-
throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
|
|
313
|
-
} else {
|
|
314
|
-
callStatus.errorBuf.deallocate()
|
|
315
|
-
throw UniffiInternalError.rustPanic("Rust panic")
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
case CALL_CANCELLED:
|
|
319
|
-
fatalError("Cancellation not supported yet")
|
|
320
|
-
|
|
321
|
-
default:
|
|
322
|
-
throw UniffiInternalError.unexpectedRustCallStatusCode
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private func uniffiTraitInterfaceCall<T>(
|
|
327
|
-
callStatus: UnsafeMutablePointer<RustCallStatus>,
|
|
328
|
-
makeCall: () throws -> T,
|
|
329
|
-
writeReturn: (T) -> ()
|
|
330
|
-
) {
|
|
331
|
-
do {
|
|
332
|
-
try writeReturn(makeCall())
|
|
333
|
-
} catch let error {
|
|
334
|
-
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
|
|
335
|
-
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
private func uniffiTraitInterfaceCallWithError<T, E>(
|
|
340
|
-
callStatus: UnsafeMutablePointer<RustCallStatus>,
|
|
341
|
-
makeCall: () throws -> T,
|
|
342
|
-
writeReturn: (T) -> (),
|
|
343
|
-
lowerError: (E) -> RustBuffer
|
|
344
|
-
) {
|
|
345
|
-
do {
|
|
346
|
-
try writeReturn(makeCall())
|
|
347
|
-
} catch let error as E {
|
|
348
|
-
callStatus.pointee.code = CALL_ERROR
|
|
349
|
-
callStatus.pointee.errorBuf = lowerError(error)
|
|
350
|
-
} catch {
|
|
351
|
-
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
|
|
352
|
-
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
|
|
356
|
-
// All mutation happens with this lock held, which is why we implement @unchecked Sendable.
|
|
357
|
-
private let lock = NSLock()
|
|
358
|
-
private var map: [UInt64: T] = [:]
|
|
359
|
-
private var currentHandle: UInt64 = 1
|
|
360
|
-
|
|
361
|
-
func insert(obj: T) -> UInt64 {
|
|
362
|
-
lock.withLock {
|
|
363
|
-
let handle = currentHandle
|
|
364
|
-
currentHandle += 1
|
|
365
|
-
map[handle] = obj
|
|
366
|
-
return handle
|
|
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
|
|
367
278
|
}
|
|
368
|
-
}
|
|
369
279
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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")
|
|
376
289
|
}
|
|
377
|
-
}
|
|
378
290
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
try lock.withLock {
|
|
382
|
-
guard let obj = map.removeValue(forKey: handle) else {
|
|
383
|
-
throw UniffiInternalError.unexpectedStaleHandle
|
|
384
|
-
}
|
|
385
|
-
return obj
|
|
386
|
-
}
|
|
387
|
-
}
|
|
291
|
+
case CALL_CANCELLED:
|
|
292
|
+
throw CancellationError()
|
|
388
293
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
map.count
|
|
392
|
-
}
|
|
294
|
+
default:
|
|
295
|
+
throw UniffiInternalError.unexpectedRustCallStatusCode
|
|
393
296
|
}
|
|
394
297
|
}
|
|
395
298
|
|
|
396
|
-
|
|
397
299
|
// Public interface members begin here.
|
|
398
|
-
// Magic number for the Rust proxy to call using the same mechanism as every other method,
|
|
399
|
-
// to free the callback once it's dropped by Rust.
|
|
400
|
-
private let IDX_CALLBACK_FREE: Int32 = 0
|
|
401
|
-
// Callback return codes
|
|
402
|
-
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
|
|
403
|
-
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
|
|
404
|
-
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
|
|
405
300
|
|
|
406
|
-
|
|
407
|
-
@_documentation(visibility: private)
|
|
408
|
-
#endif
|
|
409
|
-
fileprivate struct FfiConverterBool : FfiConverter {
|
|
301
|
+
private struct FfiConverterBool: FfiConverter {
|
|
410
302
|
typealias FfiType = Int8
|
|
411
303
|
typealias SwiftType = Bool
|
|
412
304
|
|
|
413
|
-
|
|
305
|
+
static func lift(_ value: Int8) throws -> Bool {
|
|
414
306
|
return value != 0
|
|
415
307
|
}
|
|
416
308
|
|
|
417
|
-
|
|
309
|
+
static func lower(_ value: Bool) -> Int8 {
|
|
418
310
|
return value ? 1 : 0
|
|
419
311
|
}
|
|
420
312
|
|
|
421
|
-
|
|
313
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
|
422
314
|
return try lift(readInt(&buf))
|
|
423
315
|
}
|
|
424
316
|
|
|
425
|
-
|
|
317
|
+
static func write(_ value: Bool, into buf: inout [UInt8]) {
|
|
426
318
|
writeInt(&buf, lower(value))
|
|
427
319
|
}
|
|
428
320
|
}
|
|
429
321
|
|
|
430
|
-
|
|
431
|
-
@_documentation(visibility: private)
|
|
432
|
-
#endif
|
|
433
|
-
fileprivate struct FfiConverterString: FfiConverter {
|
|
322
|
+
private struct FfiConverterString: FfiConverter {
|
|
434
323
|
typealias SwiftType = String
|
|
435
324
|
typealias FfiType = RustBuffer
|
|
436
325
|
|
|
437
|
-
|
|
326
|
+
static func lift(_ value: RustBuffer) throws -> String {
|
|
438
327
|
defer {
|
|
439
328
|
value.deallocate()
|
|
440
329
|
}
|
|
@@ -445,7 +334,7 @@ fileprivate struct FfiConverterString: FfiConverter {
|
|
|
445
334
|
return String(bytes: bytes, encoding: String.Encoding.utf8)!
|
|
446
335
|
}
|
|
447
336
|
|
|
448
|
-
|
|
337
|
+
static func lower(_ value: String) -> RustBuffer {
|
|
449
338
|
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
|
450
339
|
// The swift string gives us int8_t, we want uint8_t.
|
|
451
340
|
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
|
@@ -456,102 +345,45 @@ fileprivate struct FfiConverterString: FfiConverter {
|
|
|
456
345
|
}
|
|
457
346
|
}
|
|
458
347
|
|
|
459
|
-
|
|
348
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
|
460
349
|
let len: Int32 = try readInt(&buf)
|
|
461
|
-
return String(bytes:
|
|
350
|
+
return try String(bytes: readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
|
|
462
351
|
}
|
|
463
352
|
|
|
464
|
-
|
|
353
|
+
static func write(_ value: String, into buf: inout [UInt8]) {
|
|
465
354
|
let len = Int32(value.utf8.count)
|
|
466
355
|
writeInt(&buf, len)
|
|
467
356
|
writeBytes(&buf, value.utf8)
|
|
468
357
|
}
|
|
469
358
|
}
|
|
470
359
|
|
|
360
|
+
public protocol EventNotifierProtocol {}
|
|
471
361
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
public protocol EventNotifierProtocol: AnyObject, Sendable {
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
open class EventNotifier: EventNotifierProtocol, @unchecked Sendable {
|
|
478
|
-
fileprivate let pointer: UnsafeMutableRawPointer!
|
|
479
|
-
|
|
480
|
-
/// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
|
|
481
|
-
#if swift(>=5.8)
|
|
482
|
-
@_documentation(visibility: private)
|
|
483
|
-
#endif
|
|
484
|
-
public struct NoPointer {
|
|
485
|
-
public init() {}
|
|
486
|
-
}
|
|
362
|
+
public class EventNotifier: EventNotifierProtocol {
|
|
363
|
+
fileprivate let pointer: UnsafeMutableRawPointer
|
|
487
364
|
|
|
488
365
|
// TODO: We'd like this to be `private` but for Swifty reasons,
|
|
489
366
|
// we can't implement `FfiConverter` without making this `required` and we can't
|
|
490
367
|
// make it `required` without making it `public`.
|
|
491
|
-
|
|
492
|
-
@_documentation(visibility: private)
|
|
493
|
-
#endif
|
|
494
|
-
required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
|
|
368
|
+
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
|
|
495
369
|
self.pointer = pointer
|
|
496
370
|
}
|
|
497
371
|
|
|
498
|
-
// This constructor can be used to instantiate a fake object.
|
|
499
|
-
// - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
|
|
500
|
-
//
|
|
501
|
-
// - Warning:
|
|
502
|
-
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
|
|
503
|
-
#if swift(>=5.8)
|
|
504
|
-
@_documentation(visibility: private)
|
|
505
|
-
#endif
|
|
506
|
-
public init(noPointer: NoPointer) {
|
|
507
|
-
self.pointer = nil
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
#if swift(>=5.8)
|
|
511
|
-
@_documentation(visibility: private)
|
|
512
|
-
#endif
|
|
513
|
-
public func uniffiClonePointer() -> UnsafeMutableRawPointer {
|
|
514
|
-
return try! rustCall { uniffi_pubkycore_fn_clone_eventnotifier(self.pointer, $0) }
|
|
515
|
-
}
|
|
516
|
-
// No primary constructor declared for this class.
|
|
517
|
-
|
|
518
372
|
deinit {
|
|
519
|
-
guard let pointer = pointer else {
|
|
520
|
-
return
|
|
521
|
-
}
|
|
522
|
-
|
|
523
373
|
try! rustCall { uniffi_pubkycore_fn_free_eventnotifier(pointer, $0) }
|
|
524
374
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
375
|
}
|
|
531
376
|
|
|
532
|
-
|
|
533
|
-
#if swift(>=5.8)
|
|
534
|
-
@_documentation(visibility: private)
|
|
535
|
-
#endif
|
|
536
377
|
public struct FfiConverterTypeEventNotifier: FfiConverter {
|
|
537
|
-
|
|
538
378
|
typealias FfiType = UnsafeMutableRawPointer
|
|
539
379
|
typealias SwiftType = EventNotifier
|
|
540
380
|
|
|
541
|
-
public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
|
542
|
-
return EventNotifier(unsafeFromRawPointer: pointer)
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
public static func lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
|
|
546
|
-
return value.uniffiClonePointer()
|
|
547
|
-
}
|
|
548
|
-
|
|
549
381
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EventNotifier {
|
|
550
382
|
let v: UInt64 = try readInt(&buf)
|
|
551
383
|
// The Rust code won't compile if a pointer won't fit in a UInt64.
|
|
552
384
|
// We have to go via `UInt` because that's the thing that's the size of a pointer.
|
|
553
385
|
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
|
|
554
|
-
if
|
|
386
|
+
if ptr == nil {
|
|
555
387
|
throw UniffiInternalError.unexpectedNullPointer
|
|
556
388
|
}
|
|
557
389
|
return try lift(ptr!)
|
|
@@ -562,148 +394,194 @@ public struct FfiConverterTypeEventNotifier: FfiConverter {
|
|
|
562
394
|
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
|
|
563
395
|
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
|
|
564
396
|
}
|
|
565
|
-
}
|
|
566
397
|
|
|
398
|
+
public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
|
399
|
+
return EventNotifier(unsafeFromRawPointer: pointer)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
public static func lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
|
|
403
|
+
return value.pointer
|
|
404
|
+
}
|
|
405
|
+
}
|
|
567
406
|
|
|
568
|
-
#if swift(>=5.8)
|
|
569
|
-
@_documentation(visibility: private)
|
|
570
|
-
#endif
|
|
571
407
|
public func FfiConverterTypeEventNotifier_lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
|
572
408
|
return try FfiConverterTypeEventNotifier.lift(pointer)
|
|
573
409
|
}
|
|
574
410
|
|
|
575
|
-
#if swift(>=5.8)
|
|
576
|
-
@_documentation(visibility: private)
|
|
577
|
-
#endif
|
|
578
411
|
public func FfiConverterTypeEventNotifier_lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
|
|
579
412
|
return FfiConverterTypeEventNotifier.lower(value)
|
|
580
413
|
}
|
|
581
414
|
|
|
415
|
+
private extension NSLock {
|
|
416
|
+
func withLock<T>(f: () throws -> T) rethrows -> T {
|
|
417
|
+
lock()
|
|
418
|
+
defer { self.unlock() }
|
|
419
|
+
return try f()
|
|
420
|
+
}
|
|
421
|
+
}
|
|
582
422
|
|
|
423
|
+
private typealias UniFFICallbackHandle = UInt64
|
|
424
|
+
private class UniFFICallbackHandleMap<T> {
|
|
425
|
+
private var leftMap: [UniFFICallbackHandle: T] = [:]
|
|
426
|
+
private var counter: [UniFFICallbackHandle: UInt64] = [:]
|
|
427
|
+
private var rightMap: [ObjectIdentifier: UniFFICallbackHandle] = [:]
|
|
428
|
+
|
|
429
|
+
private let lock = NSLock()
|
|
430
|
+
private var currentHandle: UniFFICallbackHandle = 0
|
|
431
|
+
private let stride: UniFFICallbackHandle = 1
|
|
583
432
|
|
|
433
|
+
func insert(obj: T) -> UniFFICallbackHandle {
|
|
434
|
+
lock.withLock {
|
|
435
|
+
let id = ObjectIdentifier(obj as AnyObject)
|
|
436
|
+
let handle = rightMap[id] ?? {
|
|
437
|
+
currentHandle += stride
|
|
438
|
+
let handle = currentHandle
|
|
439
|
+
leftMap[handle] = obj
|
|
440
|
+
rightMap[id] = handle
|
|
441
|
+
return handle
|
|
442
|
+
}()
|
|
443
|
+
counter[handle] = (counter[handle] ?? 0) + 1
|
|
444
|
+
return handle
|
|
445
|
+
}
|
|
446
|
+
}
|
|
584
447
|
|
|
448
|
+
func get(handle: UniFFICallbackHandle) -> T? {
|
|
449
|
+
lock.withLock {
|
|
450
|
+
leftMap[handle]
|
|
451
|
+
}
|
|
452
|
+
}
|
|
585
453
|
|
|
454
|
+
func delete(handle: UniFFICallbackHandle) {
|
|
455
|
+
remove(handle: handle)
|
|
456
|
+
}
|
|
586
457
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
458
|
+
@discardableResult
|
|
459
|
+
func remove(handle: UniFFICallbackHandle) -> T? {
|
|
460
|
+
lock.withLock {
|
|
461
|
+
defer { counter[handle] = (counter[handle] ?? 1) - 1 }
|
|
462
|
+
guard counter[handle] == 1 else { return leftMap[handle] }
|
|
463
|
+
let obj = leftMap.removeValue(forKey: handle)
|
|
464
|
+
if let obj = obj {
|
|
465
|
+
rightMap.removeValue(forKey: ObjectIdentifier(obj as AnyObject))
|
|
466
|
+
}
|
|
467
|
+
return obj
|
|
468
|
+
}
|
|
469
|
+
}
|
|
591
470
|
}
|
|
592
471
|
|
|
472
|
+
// Magic number for the Rust proxy to call using the same mechanism as every other method,
|
|
473
|
+
// to free the callback once it's dropped by Rust.
|
|
474
|
+
private let IDX_CALLBACK_FREE: Int32 = 0
|
|
475
|
+
// Callback return codes
|
|
476
|
+
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
|
|
477
|
+
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
|
|
478
|
+
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
|
|
593
479
|
|
|
594
|
-
//
|
|
595
|
-
fileprivate struct UniffiCallbackInterfaceEventListener {
|
|
480
|
+
// Declaration and FfiConverters for EventListener Callback Interface
|
|
596
481
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
// This creates 1-element array, since this seems to be the only way to construct a const
|
|
601
|
-
// pointer that we can pass to the Rust code.
|
|
602
|
-
static let vtable: [UniffiVTableCallbackInterfaceEventListener] = [UniffiVTableCallbackInterfaceEventListener(
|
|
603
|
-
onEventOccurred: { (
|
|
604
|
-
uniffiHandle: UInt64,
|
|
605
|
-
eventData: RustBuffer,
|
|
606
|
-
uniffiOutReturn: UnsafeMutableRawPointer,
|
|
607
|
-
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
608
|
-
) in
|
|
609
|
-
let makeCall = {
|
|
610
|
-
() throws -> () in
|
|
611
|
-
guard let uniffiObj = try? FfiConverterCallbackInterfaceEventListener.handleMap.get(handle: uniffiHandle) else {
|
|
612
|
-
throw UniffiInternalError.unexpectedStaleHandle
|
|
613
|
-
}
|
|
614
|
-
return uniffiObj.onEventOccurred(
|
|
615
|
-
eventData: try FfiConverterString.lift(eventData)
|
|
616
|
-
)
|
|
617
|
-
}
|
|
482
|
+
public protocol EventListener: AnyObject {
|
|
483
|
+
func onEventOccurred(eventData: String)
|
|
484
|
+
}
|
|
618
485
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
486
|
+
// The ForeignCallback that is passed to Rust.
|
|
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 {
|
|
489
|
+
var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
|
|
490
|
+
func makeCall() throws -> Int32 {
|
|
491
|
+
try swiftCallbackInterface.onEventOccurred(
|
|
492
|
+
eventData: FfiConverterString.read(from: &reader)
|
|
625
493
|
)
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
494
|
+
return UNIFFI_CALLBACK_SUCCESS
|
|
495
|
+
}
|
|
496
|
+
return try makeCall()
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
switch method {
|
|
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")
|
|
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
|
|
632
519
|
}
|
|
633
|
-
)]
|
|
634
|
-
}
|
|
635
520
|
|
|
636
|
-
|
|
637
|
-
|
|
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
|
|
528
|
+
}
|
|
638
529
|
}
|
|
639
530
|
|
|
640
531
|
// FfiConverter protocol for callback interfaces
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
532
|
+
private enum FfiConverterCallbackInterfaceEventListener {
|
|
533
|
+
private static let initCallbackOnce: () = {
|
|
534
|
+
// Swift ensures this initializer code will once run once, even when accessed by multiple threads.
|
|
535
|
+
try! rustCall { (err: UnsafeMutablePointer<RustCallStatus>) in
|
|
536
|
+
uniffi_pubkycore_fn_init_callback_eventlistener(foreignCallbackCallbackInterfaceEventListener, err)
|
|
537
|
+
}
|
|
538
|
+
}()
|
|
539
|
+
|
|
540
|
+
private static func ensureCallbackinitialized() {
|
|
541
|
+
_ = initCallbackOnce
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
static func drop(handle: UniFFICallbackHandle) {
|
|
545
|
+
handleMap.remove(handle: handle)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
private static var handleMap = UniFFICallbackHandleMap<EventListener>()
|
|
646
549
|
}
|
|
647
550
|
|
|
648
|
-
|
|
649
|
-
@_documentation(visibility: private)
|
|
650
|
-
#endif
|
|
651
|
-
extension FfiConverterCallbackInterfaceEventListener : FfiConverter {
|
|
551
|
+
extension FfiConverterCallbackInterfaceEventListener: FfiConverter {
|
|
652
552
|
typealias SwiftType = EventListener
|
|
653
|
-
|
|
553
|
+
// We can use Handle as the FfiType because it's a typealias to UInt64
|
|
554
|
+
typealias FfiType = UniFFICallbackHandle
|
|
654
555
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
556
|
+
public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType {
|
|
557
|
+
ensureCallbackinitialized()
|
|
558
|
+
guard let callback = handleMap.get(handle: handle) else {
|
|
559
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
560
|
+
}
|
|
561
|
+
return callback
|
|
660
562
|
}
|
|
661
563
|
|
|
662
|
-
#if swift(>=5.8)
|
|
663
|
-
@_documentation(visibility: private)
|
|
664
|
-
#endif
|
|
665
564
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
666
|
-
|
|
565
|
+
ensureCallbackinitialized()
|
|
566
|
+
let handle: UniFFICallbackHandle = try readInt(&buf)
|
|
667
567
|
return try lift(handle)
|
|
668
568
|
}
|
|
669
569
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
#endif
|
|
673
|
-
public static func lower(_ v: SwiftType) -> UInt64 {
|
|
570
|
+
public static func lower(_ v: SwiftType) -> UniFFICallbackHandle {
|
|
571
|
+
ensureCallbackinitialized()
|
|
674
572
|
return handleMap.insert(obj: v)
|
|
675
573
|
}
|
|
676
574
|
|
|
677
|
-
#if swift(>=5.8)
|
|
678
|
-
@_documentation(visibility: private)
|
|
679
|
-
#endif
|
|
680
575
|
public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
|
|
576
|
+
ensureCallbackinitialized()
|
|
681
577
|
writeInt(&buf, lower(v))
|
|
682
578
|
}
|
|
683
579
|
}
|
|
684
580
|
|
|
685
|
-
|
|
686
|
-
#if swift(>=5.8)
|
|
687
|
-
@_documentation(visibility: private)
|
|
688
|
-
#endif
|
|
689
|
-
public func FfiConverterCallbackInterfaceEventListener_lift(_ handle: UInt64) throws -> EventListener {
|
|
690
|
-
return try FfiConverterCallbackInterfaceEventListener.lift(handle)
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
#if swift(>=5.8)
|
|
694
|
-
@_documentation(visibility: private)
|
|
695
|
-
#endif
|
|
696
|
-
public func FfiConverterCallbackInterfaceEventListener_lower(_ v: EventListener) -> UInt64 {
|
|
697
|
-
return FfiConverterCallbackInterfaceEventListener.lower(v)
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
#if swift(>=5.8)
|
|
701
|
-
@_documentation(visibility: private)
|
|
702
|
-
#endif
|
|
703
|
-
fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
581
|
+
private struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
704
582
|
typealias SwiftType = String?
|
|
705
583
|
|
|
706
|
-
|
|
584
|
+
static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|
707
585
|
guard let value = value else {
|
|
708
586
|
writeInt(&buf, Int8(0))
|
|
709
587
|
return
|
|
@@ -712,7 +590,7 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
|
712
590
|
FfiConverterString.write(value, into: &buf)
|
|
713
591
|
}
|
|
714
592
|
|
|
715
|
-
|
|
593
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
716
594
|
switch try readInt(&buf) as Int8 {
|
|
717
595
|
case 0: return nil
|
|
718
596
|
case 1: return try FfiConverterString.read(from: &buf)
|
|
@@ -721,13 +599,10 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
|
721
599
|
}
|
|
722
600
|
}
|
|
723
601
|
|
|
724
|
-
|
|
725
|
-
@_documentation(visibility: private)
|
|
726
|
-
#endif
|
|
727
|
-
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
602
|
+
private struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
728
603
|
typealias SwiftType = [String]
|
|
729
604
|
|
|
730
|
-
|
|
605
|
+
static func write(_ value: [String], into buf: inout [UInt8]) {
|
|
731
606
|
let len = Int32(value.count)
|
|
732
607
|
writeInt(&buf, len)
|
|
733
608
|
for item in value {
|
|
@@ -735,226 +610,297 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
|
735
610
|
}
|
|
736
611
|
}
|
|
737
612
|
|
|
738
|
-
|
|
613
|
+
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
|
|
739
614
|
let len: Int32 = try readInt(&buf)
|
|
740
615
|
var seq = [String]()
|
|
741
616
|
seq.reserveCapacity(Int(len))
|
|
742
617
|
for _ in 0 ..< len {
|
|
743
|
-
seq.append(
|
|
618
|
+
try seq.append(FfiConverterString.read(from: &buf))
|
|
744
619
|
}
|
|
745
620
|
return seq
|
|
746
621
|
}
|
|
747
622
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
623
|
+
|
|
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
|
+
}
|
|
753
632
|
)
|
|
754
|
-
})
|
|
755
633
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
634
|
+
|
|
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
|
+
}
|
|
761
643
|
)
|
|
762
|
-
})
|
|
763
644
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
645
|
+
|
|
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
|
+
}
|
|
769
654
|
)
|
|
770
|
-
})
|
|
771
655
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
656
|
+
|
|
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
|
+
}
|
|
777
665
|
)
|
|
778
|
-
})
|
|
779
666
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
667
|
+
|
|
668
|
+
public func generateMnemonicPhrase() -> [String] {
|
|
669
|
+
return try! FfiConverterSequenceString.lift(
|
|
670
|
+
try! rustCall {
|
|
671
|
+
uniffi_pubkycore_fn_func_generate_mnemonic_phrase($0)
|
|
672
|
+
}
|
|
783
673
|
)
|
|
784
|
-
})
|
|
785
674
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
675
|
+
|
|
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
|
+
}
|
|
789
681
|
)
|
|
790
|
-
})
|
|
791
682
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
683
|
+
|
|
684
|
+
public func generateSecretKey() -> [String] {
|
|
685
|
+
return try! FfiConverterSequenceString.lift(
|
|
686
|
+
try! rustCall {
|
|
687
|
+
uniffi_pubkycore_fn_func_generate_secret_key($0)
|
|
688
|
+
}
|
|
795
689
|
)
|
|
796
|
-
})
|
|
797
690
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
691
|
+
|
|
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
|
+
}
|
|
802
699
|
)
|
|
803
|
-
})
|
|
804
700
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
701
|
+
|
|
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
|
+
}
|
|
809
709
|
)
|
|
810
|
-
})
|
|
811
710
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
711
|
+
|
|
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
|
+
}
|
|
816
719
|
)
|
|
817
|
-
})
|
|
818
720
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
721
|
+
|
|
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
|
+
}
|
|
824
730
|
)
|
|
825
|
-
})
|
|
826
731
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
732
|
+
|
|
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
|
+
}
|
|
831
740
|
)
|
|
832
|
-
})
|
|
833
741
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
742
|
+
|
|
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
|
+
}
|
|
838
750
|
)
|
|
839
|
-
})
|
|
840
751
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
return try! FfiConverterSequenceString.lift(try! rustCall() {
|
|
850
|
-
uniffi_pubkycore_fn_func_publish(
|
|
851
|
-
FfiConverterString.lower(recordName),
|
|
852
|
-
FfiConverterString.lower(recordContent),
|
|
853
|
-
FfiConverterString.lower(secretKey),$0
|
|
752
|
+
|
|
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
|
+
}
|
|
854
760
|
)
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
public func
|
|
858
|
-
return try!
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
761
|
+
}
|
|
762
|
+
|
|
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
|
+
}
|
|
863
772
|
)
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
public func
|
|
867
|
-
return try!
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
773
|
+
}
|
|
774
|
+
|
|
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
|
+
}
|
|
872
784
|
)
|
|
873
|
-
})
|
|
874
785
|
}
|
|
875
|
-
|
|
876
|
-
|
|
786
|
+
|
|
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
|
+
}
|
|
877
796
|
)
|
|
878
797
|
}
|
|
798
|
+
|
|
799
|
+
public func removeEventListener() {
|
|
800
|
+
try! rustCall {
|
|
801
|
+
uniffi_pubkycore_fn_func_remove_event_listener($0)
|
|
802
|
+
}
|
|
879
803
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
* * Resolve a signed packet from a public key
|
|
890
|
-
* * @param public_key The public key to resolve
|
|
891
|
-
* * @returns A vector with two elements: the first element is a boolean indicating success or failure,
|
|
892
|
-
* * and the second element is the response data (either an error message or the resolved signed packet)
|
|
893
|
-
* *
|
|
894
|
-
*/
|
|
895
|
-
public func resolve(publicKey: String) -> [String] {
|
|
896
|
-
return try! FfiConverterSequenceString.lift(try! rustCall() {
|
|
897
|
-
uniffi_pubkycore_fn_func_resolve(
|
|
898
|
-
FfiConverterString.lower(publicKey),$0
|
|
804
|
+
|
|
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
|
+
}
|
|
899
813
|
)
|
|
900
|
-
})
|
|
901
814
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
815
|
+
|
|
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
|
+
}
|
|
906
823
|
)
|
|
907
|
-
})
|
|
908
824
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
825
|
+
|
|
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
|
+
}
|
|
913
833
|
)
|
|
914
|
-
})
|
|
915
834
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
835
|
+
|
|
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
|
+
}
|
|
919
843
|
)
|
|
920
844
|
}
|
|
845
|
+
|
|
846
|
+
public func setEventListener(listener: EventListener) {
|
|
847
|
+
try! rustCall {
|
|
848
|
+
uniffi_pubkycore_fn_func_set_event_listener(
|
|
849
|
+
FfiConverterCallbackInterfaceEventListener.lower(listener), $0
|
|
850
|
+
)
|
|
851
|
+
}
|
|
921
852
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
853
|
+
|
|
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
|
+
}
|
|
926
861
|
)
|
|
927
|
-
})
|
|
928
862
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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
|
+
}
|
|
933
871
|
)
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
public func signUp(secretKey: String, homeserver: String, signupToken: String?) -> [String]
|
|
937
|
-
return try!
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
872
|
+
}
|
|
873
|
+
|
|
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
|
+
}
|
|
942
883
|
)
|
|
943
|
-
})
|
|
944
884
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
885
|
+
|
|
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
|
+
}
|
|
949
893
|
)
|
|
950
|
-
})
|
|
951
894
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
895
|
+
|
|
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
|
+
}
|
|
956
903
|
)
|
|
957
|
-
})
|
|
958
904
|
}
|
|
959
905
|
|
|
960
906
|
private enum InitializationResult {
|
|
@@ -962,111 +908,109 @@ private enum InitializationResult {
|
|
|
962
908
|
case contractVersionMismatch
|
|
963
909
|
case apiChecksumMismatch
|
|
964
910
|
}
|
|
965
|
-
|
|
911
|
+
|
|
912
|
+
// Use a global variables to perform the versioning checks. Swift ensures that
|
|
966
913
|
// the code inside is only computed once.
|
|
967
|
-
private
|
|
914
|
+
private var initializationResult: InitializationResult {
|
|
968
915
|
// Get the bindings contract version from our ComponentInterface
|
|
969
|
-
let bindings_contract_version =
|
|
916
|
+
let bindings_contract_version = 24
|
|
970
917
|
// Get the scaffolding contract version by calling the into the dylib
|
|
971
918
|
let scaffolding_contract_version = ffi_pubkycore_uniffi_contract_version()
|
|
972
919
|
if bindings_contract_version != scaffolding_contract_version {
|
|
973
920
|
return InitializationResult.contractVersionMismatch
|
|
974
921
|
}
|
|
975
|
-
if
|
|
922
|
+
if uniffi_pubkycore_checksum_func_auth() != 51826 {
|
|
976
923
|
return InitializationResult.apiChecksumMismatch
|
|
977
924
|
}
|
|
978
|
-
if
|
|
925
|
+
if uniffi_pubkycore_checksum_func_create_recovery_file() != 48846 {
|
|
979
926
|
return InitializationResult.apiChecksumMismatch
|
|
980
927
|
}
|
|
981
|
-
if
|
|
928
|
+
if uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 26407 {
|
|
982
929
|
return InitializationResult.apiChecksumMismatch
|
|
983
930
|
}
|
|
984
|
-
if
|
|
931
|
+
if uniffi_pubkycore_checksum_func_delete_file() != 47931 {
|
|
985
932
|
return InitializationResult.apiChecksumMismatch
|
|
986
933
|
}
|
|
987
|
-
if
|
|
934
|
+
if uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() != 2358 {
|
|
988
935
|
return InitializationResult.apiChecksumMismatch
|
|
989
936
|
}
|
|
990
|
-
if
|
|
937
|
+
if uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() != 44395 {
|
|
991
938
|
return InitializationResult.apiChecksumMismatch
|
|
992
939
|
}
|
|
993
|
-
if
|
|
940
|
+
if uniffi_pubkycore_checksum_func_generate_secret_key() != 12800 {
|
|
994
941
|
return InitializationResult.apiChecksumMismatch
|
|
995
942
|
}
|
|
996
|
-
if
|
|
943
|
+
if uniffi_pubkycore_checksum_func_get() != 6591 {
|
|
997
944
|
return InitializationResult.apiChecksumMismatch
|
|
998
945
|
}
|
|
999
|
-
if
|
|
946
|
+
if uniffi_pubkycore_checksum_func_get_homeserver() != 40658 {
|
|
1000
947
|
return InitializationResult.apiChecksumMismatch
|
|
1001
948
|
}
|
|
1002
|
-
if
|
|
949
|
+
if uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 40316 {
|
|
1003
950
|
return InitializationResult.apiChecksumMismatch
|
|
1004
951
|
}
|
|
1005
|
-
if
|
|
952
|
+
if uniffi_pubkycore_checksum_func_get_signup_token() != 47927 {
|
|
1006
953
|
return InitializationResult.apiChecksumMismatch
|
|
1007
954
|
}
|
|
1008
|
-
if
|
|
955
|
+
if uniffi_pubkycore_checksum_func_list() != 43198 {
|
|
1009
956
|
return InitializationResult.apiChecksumMismatch
|
|
1010
957
|
}
|
|
1011
|
-
if
|
|
958
|
+
if uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() != 45784 {
|
|
1012
959
|
return InitializationResult.apiChecksumMismatch
|
|
1013
960
|
}
|
|
1014
|
-
if
|
|
961
|
+
if uniffi_pubkycore_checksum_func_parse_auth_url() != 27379 {
|
|
1015
962
|
return InitializationResult.apiChecksumMismatch
|
|
1016
963
|
}
|
|
1017
|
-
if
|
|
964
|
+
if uniffi_pubkycore_checksum_func_publish() != 48989 {
|
|
1018
965
|
return InitializationResult.apiChecksumMismatch
|
|
1019
966
|
}
|
|
1020
|
-
if
|
|
967
|
+
if uniffi_pubkycore_checksum_func_publish_https() != 5614 {
|
|
1021
968
|
return InitializationResult.apiChecksumMismatch
|
|
1022
969
|
}
|
|
1023
|
-
if
|
|
970
|
+
if uniffi_pubkycore_checksum_func_put() != 64514 {
|
|
1024
971
|
return InitializationResult.apiChecksumMismatch
|
|
1025
972
|
}
|
|
1026
|
-
if
|
|
973
|
+
if uniffi_pubkycore_checksum_func_remove_event_listener() != 23534 {
|
|
1027
974
|
return InitializationResult.apiChecksumMismatch
|
|
1028
975
|
}
|
|
1029
|
-
if
|
|
976
|
+
if uniffi_pubkycore_checksum_func_republish_homeserver() != 63919 {
|
|
1030
977
|
return InitializationResult.apiChecksumMismatch
|
|
1031
978
|
}
|
|
1032
|
-
if
|
|
979
|
+
if uniffi_pubkycore_checksum_func_resolve() != 34317 {
|
|
1033
980
|
return InitializationResult.apiChecksumMismatch
|
|
1034
981
|
}
|
|
1035
|
-
if
|
|
982
|
+
if uniffi_pubkycore_checksum_func_resolve_https() != 17266 {
|
|
1036
983
|
return InitializationResult.apiChecksumMismatch
|
|
1037
984
|
}
|
|
1038
|
-
if
|
|
985
|
+
if uniffi_pubkycore_checksum_func_revalidate_session() != 57726 {
|
|
1039
986
|
return InitializationResult.apiChecksumMismatch
|
|
1040
987
|
}
|
|
1041
|
-
if
|
|
988
|
+
if uniffi_pubkycore_checksum_func_set_event_listener() != 60071 {
|
|
1042
989
|
return InitializationResult.apiChecksumMismatch
|
|
1043
990
|
}
|
|
1044
|
-
if
|
|
991
|
+
if uniffi_pubkycore_checksum_func_sign_in() != 21584 {
|
|
1045
992
|
return InitializationResult.apiChecksumMismatch
|
|
1046
993
|
}
|
|
1047
|
-
if
|
|
994
|
+
if uniffi_pubkycore_checksum_func_sign_out() != 27163 {
|
|
1048
995
|
return InitializationResult.apiChecksumMismatch
|
|
1049
996
|
}
|
|
1050
|
-
if
|
|
997
|
+
if uniffi_pubkycore_checksum_func_sign_up() != 48789 {
|
|
1051
998
|
return InitializationResult.apiChecksumMismatch
|
|
1052
999
|
}
|
|
1053
|
-
if
|
|
1000
|
+
if uniffi_pubkycore_checksum_func_switch_network() != 64215 {
|
|
1054
1001
|
return InitializationResult.apiChecksumMismatch
|
|
1055
1002
|
}
|
|
1056
|
-
if
|
|
1003
|
+
if uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() != 30362 {
|
|
1057
1004
|
return InitializationResult.apiChecksumMismatch
|
|
1058
1005
|
}
|
|
1059
|
-
if
|
|
1006
|
+
if uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 11531 {
|
|
1060
1007
|
return InitializationResult.apiChecksumMismatch
|
|
1061
1008
|
}
|
|
1062
1009
|
|
|
1063
|
-
uniffiCallbackInitEventListener()
|
|
1064
1010
|
return InitializationResult.ok
|
|
1065
|
-
}
|
|
1011
|
+
}
|
|
1066
1012
|
|
|
1067
|
-
|
|
1068
|
-
// our types can call it.
|
|
1069
|
-
public func uniffiEnsurePubkycoreInitialized() {
|
|
1013
|
+
private func uniffiEnsureInitialized() {
|
|
1070
1014
|
switch initializationResult {
|
|
1071
1015
|
case .ok:
|
|
1072
1016
|
break
|
|
@@ -1076,5 +1020,3 @@ public func uniffiEnsurePubkycoreInitialized() {
|
|
|
1076
1020
|
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1077
1021
|
}
|
|
1078
1022
|
}
|
|
1079
|
-
|
|
1080
|
-
// swiftlint:enable all
|