@synonymdev/react-native-pubky 0.10.6 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
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
3
5
  import Foundation
4
6
 
5
7
  // Depending on the consumer's build setup, the low-level FFI code
@@ -18,6 +20,10 @@ fileprivate extension RustBuffer {
18
20
  self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
19
21
  }
20
22
 
23
+ static func empty() -> RustBuffer {
24
+ RustBuffer(capacity: 0, len:0, data: nil)
25
+ }
26
+
21
27
  static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
22
28
  try! rustCall { ffi_pubkycore_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
23
29
  }
@@ -44,9 +50,11 @@ fileprivate extension ForeignBytes {
44
50
 
45
51
  fileprivate extension Data {
46
52
  init(rustBuffer: RustBuffer) {
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))
53
+ self.init(
54
+ bytesNoCopy: rustBuffer.data!,
55
+ count: Int(rustBuffer.len),
56
+ deallocator: .none
57
+ )
50
58
  }
51
59
  }
52
60
 
@@ -147,7 +155,7 @@ fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
147
155
  }
148
156
 
149
157
  // Protocol for types that transfer other types across the FFI. This is
150
- // analogous go the Rust trait of the same name.
158
+ // analogous to the Rust trait of the same name.
151
159
  fileprivate protocol FfiConverter {
152
160
  associatedtype FfiType
153
161
  associatedtype SwiftType
@@ -162,10 +170,16 @@ fileprivate protocol FfiConverter {
162
170
  fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
163
171
 
164
172
  extension FfiConverterPrimitive {
173
+ #if swift(>=5.8)
174
+ @_documentation(visibility: private)
175
+ #endif
165
176
  public static func lift(_ value: FfiType) throws -> SwiftType {
166
177
  return value
167
178
  }
168
179
 
180
+ #if swift(>=5.8)
181
+ @_documentation(visibility: private)
182
+ #endif
169
183
  public static func lower(_ value: SwiftType) -> FfiType {
170
184
  return value
171
185
  }
@@ -176,6 +190,9 @@ extension FfiConverterPrimitive {
176
190
  fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
177
191
 
178
192
  extension FfiConverterRustBuffer {
193
+ #if swift(>=5.8)
194
+ @_documentation(visibility: private)
195
+ #endif
179
196
  public static func lift(_ buf: RustBuffer) throws -> SwiftType {
180
197
  var reader = createReader(data: Data(rustBuffer: buf))
181
198
  let value = try read(from: &reader)
@@ -186,6 +203,9 @@ extension FfiConverterRustBuffer {
186
203
  return value
187
204
  }
188
205
 
206
+ #if swift(>=5.8)
207
+ @_documentation(visibility: private)
208
+ #endif
189
209
  public static func lower(_ value: SwiftType) -> RustBuffer {
190
210
  var writer = createWriter()
191
211
  write(value, into: &writer)
@@ -220,9 +240,17 @@ fileprivate enum UniffiInternalError: LocalizedError {
220
240
  }
221
241
  }
222
242
 
243
+ fileprivate extension NSLock {
244
+ func withLock<T>(f: () throws -> T) rethrows -> T {
245
+ self.lock()
246
+ defer { self.unlock() }
247
+ return try f()
248
+ }
249
+ }
250
+
223
251
  fileprivate let CALL_SUCCESS: Int8 = 0
224
252
  fileprivate let CALL_ERROR: Int8 = 1
225
- fileprivate let CALL_PANIC: Int8 = 2
253
+ fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
226
254
  fileprivate let CALL_CANCELLED: Int8 = 3
227
255
 
228
256
  fileprivate extension RustCallStatus {
@@ -239,29 +267,30 @@ fileprivate extension RustCallStatus {
239
267
  }
240
268
 
241
269
  private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
242
- try makeRustCall(callback, errorHandler: nil)
270
+ let neverThrow: ((RustBuffer) throws -> Never)? = nil
271
+ return try makeRustCall(callback, errorHandler: neverThrow)
243
272
  }
244
273
 
245
- private func rustCallWithError<T>(
246
- _ errorHandler: @escaping (RustBuffer) throws -> Error,
274
+ private func rustCallWithError<T, E: Swift.Error>(
275
+ _ errorHandler: @escaping (RustBuffer) throws -> E,
247
276
  _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
248
277
  try makeRustCall(callback, errorHandler: errorHandler)
249
278
  }
250
279
 
251
- private func makeRustCall<T>(
280
+ private func makeRustCall<T, E: Swift.Error>(
252
281
  _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
253
- errorHandler: ((RustBuffer) throws -> Error)?
282
+ errorHandler: ((RustBuffer) throws -> E)?
254
283
  ) throws -> T {
255
- uniffiEnsureInitialized()
284
+ uniffiEnsurePubkycoreInitialized()
256
285
  var callStatus = RustCallStatus.init()
257
286
  let returnedVal = callback(&callStatus)
258
287
  try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
259
288
  return returnedVal
260
289
  }
261
290
 
262
- private func uniffiCheckCallStatus(
291
+ private func uniffiCheckCallStatus<E: Swift.Error>(
263
292
  callStatus: RustCallStatus,
264
- errorHandler: ((RustBuffer) throws -> Error)?
293
+ errorHandler: ((RustBuffer) throws -> E)?
265
294
  ) throws {
266
295
  switch callStatus.code {
267
296
  case CALL_SUCCESS:
@@ -275,7 +304,7 @@ private func uniffiCheckCallStatus(
275
304
  throw UniffiInternalError.unexpectedRustCallError
276
305
  }
277
306
 
278
- case CALL_PANIC:
307
+ case CALL_UNEXPECTED_ERROR:
279
308
  // When the rust code sees a panic, it tries to construct a RustBuffer
280
309
  // with the message. But if that code panics, then it just sends back
281
310
  // an empty buffer.
@@ -287,16 +316,96 @@ private func uniffiCheckCallStatus(
287
316
  }
288
317
 
289
318
  case CALL_CANCELLED:
290
- throw CancellationError()
319
+ fatalError("Cancellation not supported yet")
291
320
 
292
321
  default:
293
322
  throw UniffiInternalError.unexpectedRustCallStatusCode
294
323
  }
295
324
  }
296
325
 
297
- // Public interface members begin here.
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
367
+ }
368
+ }
369
+
370
+ func get(handle: UInt64) throws -> T {
371
+ try lock.withLock {
372
+ guard let obj = map[handle] else {
373
+ throw UniffiInternalError.unexpectedStaleHandle
374
+ }
375
+ return obj
376
+ }
377
+ }
378
+
379
+ @discardableResult
380
+ func remove(handle: UInt64) throws -> T {
381
+ try lock.withLock {
382
+ guard let obj = map.removeValue(forKey: handle) else {
383
+ throw UniffiInternalError.unexpectedStaleHandle
384
+ }
385
+ return obj
386
+ }
387
+ }
388
+
389
+ var count: Int {
390
+ get {
391
+ map.count
392
+ }
393
+ }
394
+ }
298
395
 
299
396
 
397
+ // 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
+
406
+ #if swift(>=5.8)
407
+ @_documentation(visibility: private)
408
+ #endif
300
409
  fileprivate struct FfiConverterBool : FfiConverter {
301
410
  typealias FfiType = Int8
302
411
  typealias SwiftType = Bool
@@ -318,6 +427,9 @@ fileprivate struct FfiConverterBool : FfiConverter {
318
427
  }
319
428
  }
320
429
 
430
+ #if swift(>=5.8)
431
+ @_documentation(visibility: private)
432
+ #endif
321
433
  fileprivate struct FfiConverterString: FfiConverter {
322
434
  typealias SwiftType = String
323
435
  typealias FfiType = RustBuffer
@@ -357,34 +469,83 @@ fileprivate struct FfiConverterString: FfiConverter {
357
469
  }
358
470
 
359
471
 
360
- public protocol EventNotifierProtocol {
472
+
473
+
474
+ public protocol EventNotifierProtocol: AnyObject, Sendable {
361
475
 
362
476
  }
477
+ open class EventNotifier: EventNotifierProtocol, @unchecked Sendable {
478
+ fileprivate let pointer: UnsafeMutableRawPointer!
363
479
 
364
- public class EventNotifier: EventNotifierProtocol {
365
- fileprivate let pointer: UnsafeMutableRawPointer
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
+ }
366
487
 
367
488
  // TODO: We'd like this to be `private` but for Swifty reasons,
368
489
  // we can't implement `FfiConverter` without making this `required` and we can't
369
490
  // make it `required` without making it `public`.
370
- required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
491
+ #if swift(>=5.8)
492
+ @_documentation(visibility: private)
493
+ #endif
494
+ required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
371
495
  self.pointer = pointer
372
496
  }
373
497
 
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
+
374
518
  deinit {
519
+ guard let pointer = pointer else {
520
+ return
521
+ }
522
+
375
523
  try! rustCall { uniffi_pubkycore_fn_free_eventnotifier(pointer, $0) }
376
524
  }
377
525
 
378
526
 
379
527
 
380
528
 
381
-
529
+
382
530
  }
383
531
 
532
+
533
+ #if swift(>=5.8)
534
+ @_documentation(visibility: private)
535
+ #endif
384
536
  public struct FfiConverterTypeEventNotifier: FfiConverter {
537
+
385
538
  typealias FfiType = UnsafeMutableRawPointer
386
539
  typealias SwiftType = EventNotifier
387
540
 
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
+
388
549
  public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EventNotifier {
389
550
  let v: UInt64 = try readInt(&buf)
390
551
  // The Rust code won't compile if a pointer won't fit in a UInt64.
@@ -401,195 +562,144 @@ public struct FfiConverterTypeEventNotifier: FfiConverter {
401
562
  // The Rust code won't compile if a pointer won't fit in a `UInt64`.
402
563
  writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
403
564
  }
404
-
405
- public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
406
- return EventNotifier(unsafeFromRawPointer: pointer)
407
- }
408
-
409
- public static func lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
410
- return value.pointer
411
- }
412
565
  }
413
566
 
414
567
 
568
+ #if swift(>=5.8)
569
+ @_documentation(visibility: private)
570
+ #endif
415
571
  public func FfiConverterTypeEventNotifier_lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
416
572
  return try FfiConverterTypeEventNotifier.lift(pointer)
417
573
  }
418
574
 
575
+ #if swift(>=5.8)
576
+ @_documentation(visibility: private)
577
+ #endif
419
578
  public func FfiConverterTypeEventNotifier_lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
420
579
  return FfiConverterTypeEventNotifier.lower(value)
421
580
  }
422
581
 
423
- fileprivate extension NSLock {
424
- func withLock<T>(f: () throws -> T) rethrows -> T {
425
- self.lock()
426
- defer { self.unlock() }
427
- return try f()
428
- }
429
- }
430
582
 
431
- fileprivate typealias UniFFICallbackHandle = UInt64
432
- fileprivate class UniFFICallbackHandleMap<T> {
433
- private var leftMap: [UniFFICallbackHandle: T] = [:]
434
- private var counter: [UniFFICallbackHandle: UInt64] = [:]
435
- private var rightMap: [ObjectIdentifier: UniFFICallbackHandle] = [:]
436
583
 
437
- private let lock = NSLock()
438
- private var currentHandle: UniFFICallbackHandle = 0
439
- private let stride: UniFFICallbackHandle = 1
440
584
 
441
- func insert(obj: T) -> UniFFICallbackHandle {
442
- lock.withLock {
443
- let id = ObjectIdentifier(obj as AnyObject)
444
- let handle = rightMap[id] ?? {
445
- currentHandle += stride
446
- let handle = currentHandle
447
- leftMap[handle] = obj
448
- rightMap[id] = handle
449
- return handle
450
- }()
451
- counter[handle] = (counter[handle] ?? 0) + 1
452
- return handle
453
- }
454
- }
455
585
 
456
- func get(handle: UniFFICallbackHandle) -> T? {
457
- lock.withLock {
458
- leftMap[handle]
459
- }
460
- }
461
586
 
462
- func delete(handle: UniFFICallbackHandle) {
463
- remove(handle: handle)
464
- }
465
-
466
- @discardableResult
467
- func remove(handle: UniFFICallbackHandle) -> T? {
468
- lock.withLock {
469
- defer { counter[handle] = (counter[handle] ?? 1) - 1 }
470
- guard counter[handle] == 1 else { return leftMap[handle] }
471
- let obj = leftMap.removeValue(forKey: handle)
472
- if let obj = obj {
473
- rightMap.removeValue(forKey: ObjectIdentifier(obj as AnyObject))
474
- }
475
- return obj
476
- }
477
- }
478
- }
479
-
480
- // Magic number for the Rust proxy to call using the same mechanism as every other method,
481
- // to free the callback once it's dropped by Rust.
482
- private let IDX_CALLBACK_FREE: Int32 = 0
483
- // Callback return codes
484
- private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
485
- private let UNIFFI_CALLBACK_ERROR: Int32 = 1
486
- private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
487
-
488
- // Declaration and FfiConverters for EventListener Callback Interface
489
-
490
- public protocol EventListener : AnyObject {
587
+ public protocol EventListener: AnyObject, Sendable {
588
+
491
589
  func onEventOccurred(eventData: String)
492
590
 
493
591
  }
494
592
 
495
- // The ForeignCallback that is passed to Rust.
496
- fileprivate let foreignCallbackCallbackInterfaceEventListener : ForeignCallback =
497
- { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer<UInt8>, argsLen: Int32, out_buf: UnsafeMutablePointer<RustBuffer>) -> Int32 in
498
-
499
593
 
500
- func invokeOnEventOccurred(_ swiftCallbackInterface: EventListener, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
501
- var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
502
- func makeCall() throws -> Int32 {
503
- try swiftCallbackInterface.onEventOccurred(
504
- eventData: try FfiConverterString.read(from: &reader)
505
- )
506
- return UNIFFI_CALLBACK_SUCCESS
507
- }
508
- return try makeCall()
509
- }
510
-
511
-
512
- switch method {
513
- case IDX_CALLBACK_FREE:
514
- FfiConverterCallbackInterfaceEventListener.drop(handle: handle)
515
- // Sucessful return
516
- // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
517
- return UNIFFI_CALLBACK_SUCCESS
518
- case 1:
519
- let cb: EventListener
520
- do {
521
- cb = try FfiConverterCallbackInterfaceEventListener.lift(handle)
522
- } catch {
523
- out_buf.pointee = FfiConverterString.lower("EventListener: Invalid handle")
524
- return UNIFFI_CALLBACK_UNEXPECTED_ERROR
594
+ // Put the implementation in a struct so we don't pollute the top-level namespace
595
+ fileprivate struct UniffiCallbackInterfaceEventListener {
596
+
597
+ // Create the VTable using a series of closures.
598
+ // Swift automatically converts these into C callback functions.
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
+ )
525
617
  }
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
618
+
619
+
620
+ let writeReturn = { () }
621
+ uniffiTraitInterfaceCall(
622
+ callStatus: uniffiCallStatus,
623
+ makeCall: makeCall,
624
+ writeReturn: writeReturn
625
+ )
626
+ },
627
+ uniffiFree: { (uniffiHandle: UInt64) -> () in
628
+ let result = try? FfiConverterCallbackInterfaceEventListener.handleMap.remove(handle: uniffiHandle)
629
+ if result == nil {
630
+ print("Uniffi callback interface EventListener: handle missing in uniffiFree")
531
631
  }
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`
539
- return UNIFFI_CALLBACK_UNEXPECTED_ERROR
540
- }
632
+ }
633
+ )]
634
+ }
635
+
636
+ private func uniffiCallbackInitEventListener() {
637
+ uniffi_pubkycore_fn_init_callback_vtable_eventlistener(UniffiCallbackInterfaceEventListener.vtable)
541
638
  }
542
639
 
543
640
  // FfiConverter protocol for callback interfaces
641
+ #if swift(>=5.8)
642
+ @_documentation(visibility: private)
643
+ #endif
544
644
  fileprivate struct FfiConverterCallbackInterfaceEventListener {
545
- private static let initCallbackOnce: () = {
546
- // Swift ensures this initializer code will once run once, even when accessed by multiple threads.
547
- try! rustCall { (err: UnsafeMutablePointer<RustCallStatus>) in
548
- uniffi_pubkycore_fn_init_callback_eventlistener(foreignCallbackCallbackInterfaceEventListener, err)
549
- }
550
- }()
551
-
552
- private static func ensureCallbackinitialized() {
553
- _ = initCallbackOnce
554
- }
555
-
556
- static func drop(handle: UniFFICallbackHandle) {
557
- handleMap.remove(handle: handle)
558
- }
559
-
560
- private static var handleMap = UniFFICallbackHandleMap<EventListener>()
645
+ fileprivate static let handleMap = UniffiHandleMap<EventListener>()
561
646
  }
562
647
 
648
+ #if swift(>=5.8)
649
+ @_documentation(visibility: private)
650
+ #endif
563
651
  extension FfiConverterCallbackInterfaceEventListener : FfiConverter {
564
652
  typealias SwiftType = EventListener
565
- // We can use Handle as the FfiType because it's a typealias to UInt64
566
- typealias FfiType = UniFFICallbackHandle
653
+ typealias FfiType = UInt64
567
654
 
568
- public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType {
569
- ensureCallbackinitialized();
570
- guard let callback = handleMap.get(handle: handle) else {
571
- throw UniffiInternalError.unexpectedStaleHandle
572
- }
573
- return callback
655
+ #if swift(>=5.8)
656
+ @_documentation(visibility: private)
657
+ #endif
658
+ public static func lift(_ handle: UInt64) throws -> SwiftType {
659
+ try handleMap.get(handle: handle)
574
660
  }
575
661
 
662
+ #if swift(>=5.8)
663
+ @_documentation(visibility: private)
664
+ #endif
576
665
  public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
577
- ensureCallbackinitialized();
578
- let handle: UniFFICallbackHandle = try readInt(&buf)
666
+ let handle: UInt64 = try readInt(&buf)
579
667
  return try lift(handle)
580
668
  }
581
669
 
582
- public static func lower(_ v: SwiftType) -> UniFFICallbackHandle {
583
- ensureCallbackinitialized();
670
+ #if swift(>=5.8)
671
+ @_documentation(visibility: private)
672
+ #endif
673
+ public static func lower(_ v: SwiftType) -> UInt64 {
584
674
  return handleMap.insert(obj: v)
585
675
  }
586
676
 
677
+ #if swift(>=5.8)
678
+ @_documentation(visibility: private)
679
+ #endif
587
680
  public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
588
- ensureCallbackinitialized();
589
681
  writeInt(&buf, lower(v))
590
682
  }
591
683
  }
592
684
 
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
593
703
  fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
594
704
  typealias SwiftType = String?
595
705
 
@@ -611,6 +721,9 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
611
721
  }
612
722
  }
613
723
 
724
+ #if swift(>=5.8)
725
+ @_documentation(visibility: private)
726
+ #endif
614
727
  fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
615
728
  typealias SwiftType = [String]
616
729
 
@@ -632,265 +745,216 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
632
745
  return seq
633
746
  }
634
747
  }
635
-
636
- public func auth(url: String, secretKey: String) -> [String] {
637
- return try! FfiConverterSequenceString.lift(
638
- try! rustCall() {
748
+ public func auth(url: String, secretKey: String) -> [String] {
749
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
639
750
  uniffi_pubkycore_fn_func_auth(
640
751
  FfiConverterString.lower(url),
641
- FfiConverterString.lower(secretKey),$0)
642
- }
752
+ FfiConverterString.lower(secretKey),$0
643
753
  )
754
+ })
644
755
  }
645
-
646
- public func createRecoveryFile(secretKey: String, passphrase: String) -> [String] {
647
- return try! FfiConverterSequenceString.lift(
648
- try! rustCall() {
756
+ public func createRecoveryFile(secretKey: String, passphrase: String) -> [String] {
757
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
649
758
  uniffi_pubkycore_fn_func_create_recovery_file(
650
759
  FfiConverterString.lower(secretKey),
651
- FfiConverterString.lower(passphrase),$0)
652
- }
760
+ FfiConverterString.lower(passphrase),$0
653
761
  )
762
+ })
654
763
  }
655
-
656
- public func decryptRecoveryFile(recoveryFile: String, passphrase: String) -> [String] {
657
- return try! FfiConverterSequenceString.lift(
658
- try! rustCall() {
764
+ public func decryptRecoveryFile(recoveryFile: String, passphrase: String) -> [String] {
765
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
659
766
  uniffi_pubkycore_fn_func_decrypt_recovery_file(
660
767
  FfiConverterString.lower(recoveryFile),
661
- FfiConverterString.lower(passphrase),$0)
662
- }
768
+ FfiConverterString.lower(passphrase),$0
663
769
  )
770
+ })
664
771
  }
665
-
666
- public func deleteFile(url: String) -> [String] {
667
- return try! FfiConverterSequenceString.lift(
668
- try! rustCall() {
772
+ public func deleteFile(url: String, secretKey: String) -> [String] {
773
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
669
774
  uniffi_pubkycore_fn_func_delete_file(
670
- FfiConverterString.lower(url),$0)
671
- }
775
+ FfiConverterString.lower(url),
776
+ FfiConverterString.lower(secretKey),$0
672
777
  )
778
+ })
673
779
  }
674
-
675
- public func generateMnemonicPhrase() -> [String] {
676
- return try! FfiConverterSequenceString.lift(
677
- try! rustCall() {
678
- uniffi_pubkycore_fn_func_generate_mnemonic_phrase($0)
679
- }
780
+ public func generateMnemonicPhrase() -> [String] {
781
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
782
+ uniffi_pubkycore_fn_func_generate_mnemonic_phrase($0
680
783
  )
784
+ })
681
785
  }
682
-
683
- public func generateMnemonicPhraseAndKeypair() -> [String] {
684
- return try! FfiConverterSequenceString.lift(
685
- try! rustCall() {
686
- uniffi_pubkycore_fn_func_generate_mnemonic_phrase_and_keypair($0)
687
- }
786
+ public func generateMnemonicPhraseAndKeypair() -> [String] {
787
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
788
+ uniffi_pubkycore_fn_func_generate_mnemonic_phrase_and_keypair($0
688
789
  )
790
+ })
689
791
  }
690
-
691
- public func generateSecretKey() -> [String] {
692
- return try! FfiConverterSequenceString.lift(
693
- try! rustCall() {
694
- uniffi_pubkycore_fn_func_generate_secret_key($0)
695
- }
792
+ public func generateSecretKey() -> [String] {
793
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
794
+ uniffi_pubkycore_fn_func_generate_secret_key($0
696
795
  )
796
+ })
697
797
  }
698
-
699
- public func get(url: String) -> [String] {
700
- return try! FfiConverterSequenceString.lift(
701
- try! rustCall() {
798
+ public func get(url: String) -> [String] {
799
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
702
800
  uniffi_pubkycore_fn_func_get(
703
- FfiConverterString.lower(url),$0)
704
- }
801
+ FfiConverterString.lower(url),$0
705
802
  )
803
+ })
706
804
  }
707
-
708
- public func getHomeserver(pubky: String) -> [String] {
709
- return try! FfiConverterSequenceString.lift(
710
- try! rustCall() {
805
+ public func getHomeserver(pubky: String) -> [String] {
806
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
711
807
  uniffi_pubkycore_fn_func_get_homeserver(
712
- FfiConverterString.lower(pubky),$0)
713
- }
808
+ FfiConverterString.lower(pubky),$0
714
809
  )
810
+ })
715
811
  }
716
-
717
- public func getPublicKeyFromSecretKey(secretKey: String) -> [String] {
718
- return try! FfiConverterSequenceString.lift(
719
- try! rustCall() {
812
+ public func getPublicKeyFromSecretKey(secretKey: String) -> [String] {
813
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
720
814
  uniffi_pubkycore_fn_func_get_public_key_from_secret_key(
721
- FfiConverterString.lower(secretKey),$0)
722
- }
815
+ FfiConverterString.lower(secretKey),$0
723
816
  )
817
+ })
724
818
  }
725
-
726
- public func getSignupToken(homeserverPubky: String, adminPassword: String) -> [String] {
727
- return try! FfiConverterSequenceString.lift(
728
- try! rustCall() {
819
+ public func getSignupToken(homeserverPubky: String, adminPassword: String) -> [String] {
820
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
729
821
  uniffi_pubkycore_fn_func_get_signup_token(
730
822
  FfiConverterString.lower(homeserverPubky),
731
- FfiConverterString.lower(adminPassword),$0)
732
- }
823
+ FfiConverterString.lower(adminPassword),$0
733
824
  )
825
+ })
734
826
  }
735
-
736
- public func list(url: String) -> [String] {
737
- return try! FfiConverterSequenceString.lift(
738
- try! rustCall() {
827
+ public func list(url: String) -> [String] {
828
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
739
829
  uniffi_pubkycore_fn_func_list(
740
- FfiConverterString.lower(url),$0)
741
- }
830
+ FfiConverterString.lower(url),$0
742
831
  )
832
+ })
743
833
  }
744
-
745
- public func mnemonicPhraseToKeypair(mnemonicPhrase: String) -> [String] {
746
- return try! FfiConverterSequenceString.lift(
747
- try! rustCall() {
834
+ public func mnemonicPhraseToKeypair(mnemonicPhrase: String) -> [String] {
835
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
748
836
  uniffi_pubkycore_fn_func_mnemonic_phrase_to_keypair(
749
- FfiConverterString.lower(mnemonicPhrase),$0)
750
- }
837
+ FfiConverterString.lower(mnemonicPhrase),$0
751
838
  )
839
+ })
752
840
  }
753
-
754
- public func parseAuthUrl(url: String) -> [String] {
755
- return try! FfiConverterSequenceString.lift(
756
- try! rustCall() {
841
+ public func parseAuthUrl(url: String) -> [String] {
842
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
757
843
  uniffi_pubkycore_fn_func_parse_auth_url(
758
- FfiConverterString.lower(url),$0)
759
- }
844
+ FfiConverterString.lower(url),$0
760
845
  )
846
+ })
761
847
  }
762
-
763
- public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
764
- return try! FfiConverterSequenceString.lift(
765
- try! rustCall() {
848
+ public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
849
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
766
850
  uniffi_pubkycore_fn_func_publish(
767
851
  FfiConverterString.lower(recordName),
768
852
  FfiConverterString.lower(recordContent),
769
- FfiConverterString.lower(secretKey),$0)
770
- }
853
+ FfiConverterString.lower(secretKey),$0
771
854
  )
855
+ })
772
856
  }
773
-
774
- public func publishHttps(recordName: String, target: String, secretKey: String) -> [String] {
775
- return try! FfiConverterSequenceString.lift(
776
- try! rustCall() {
857
+ public func publishHttps(recordName: String, target: String, secretKey: String) -> [String] {
858
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
777
859
  uniffi_pubkycore_fn_func_publish_https(
778
860
  FfiConverterString.lower(recordName),
779
861
  FfiConverterString.lower(target),
780
- FfiConverterString.lower(secretKey),$0)
781
- }
862
+ FfiConverterString.lower(secretKey),$0
782
863
  )
864
+ })
783
865
  }
784
-
785
- public func put(url: String, content: String) -> [String] {
786
- return try! FfiConverterSequenceString.lift(
787
- try! rustCall() {
866
+ public func put(url: String, content: String, secretKey: String) -> [String] {
867
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
788
868
  uniffi_pubkycore_fn_func_put(
789
869
  FfiConverterString.lower(url),
790
- FfiConverterString.lower(content),$0)
791
- }
870
+ FfiConverterString.lower(content),
871
+ FfiConverterString.lower(secretKey),$0
792
872
  )
873
+ })
793
874
  }
794
-
795
- public func removeEventListener() {
796
- try! rustCall() {
797
- uniffi_pubkycore_fn_func_remove_event_listener($0)
875
+ public func removeEventListener() {try! rustCall() {
876
+ uniffi_pubkycore_fn_func_remove_event_listener($0
877
+ )
798
878
  }
799
879
  }
800
-
801
-
802
-
803
- public func republishHomeserver(secretKey: String, homeserver: String) -> [String] {
804
- return try! FfiConverterSequenceString.lift(
805
- try! rustCall() {
880
+ public func republishHomeserver(secretKey: String, homeserver: String) -> [String] {
881
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
806
882
  uniffi_pubkycore_fn_func_republish_homeserver(
807
883
  FfiConverterString.lower(secretKey),
808
- FfiConverterString.lower(homeserver),$0)
809
- }
884
+ FfiConverterString.lower(homeserver),$0
810
885
  )
811
- }
812
-
813
- public func resolve(publicKey: String) -> [String] {
814
- return try! FfiConverterSequenceString.lift(
815
- try! rustCall() {
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() {
816
897
  uniffi_pubkycore_fn_func_resolve(
817
- FfiConverterString.lower(publicKey),$0)
818
- }
898
+ FfiConverterString.lower(publicKey),$0
819
899
  )
900
+ })
820
901
  }
821
-
822
- public func resolveHttps(publicKey: String) -> [String] {
823
- return try! FfiConverterSequenceString.lift(
824
- try! rustCall() {
902
+ public func resolveHttps(publicKey: String) -> [String] {
903
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
825
904
  uniffi_pubkycore_fn_func_resolve_https(
826
- FfiConverterString.lower(publicKey),$0)
827
- }
905
+ FfiConverterString.lower(publicKey),$0
828
906
  )
907
+ })
829
908
  }
830
-
831
- public func session(pubky: String) -> [String] {
832
- return try! FfiConverterSequenceString.lift(
833
- try! rustCall() {
834
- uniffi_pubkycore_fn_func_session(
835
- FfiConverterString.lower(pubky),$0)
836
- }
909
+ public func revalidateSession(sessionSecret: String) -> [String] {
910
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
911
+ uniffi_pubkycore_fn_func_revalidate_session(
912
+ FfiConverterString.lower(sessionSecret),$0
837
913
  )
914
+ })
838
915
  }
839
-
840
- public func setEventListener(listener: EventListener) {
841
- try! rustCall() {
916
+ public func setEventListener(listener: EventListener) {try! rustCall() {
842
917
  uniffi_pubkycore_fn_func_set_event_listener(
843
- FfiConverterCallbackInterfaceEventListener.lower(listener),$0)
918
+ FfiConverterCallbackInterfaceEventListener_lower(listener),$0
919
+ )
844
920
  }
845
921
  }
846
-
847
-
848
-
849
- public func signIn(secretKey: String) -> [String] {
850
- return try! FfiConverterSequenceString.lift(
851
- try! rustCall() {
922
+ public func signIn(secretKey: String) -> [String] {
923
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
852
924
  uniffi_pubkycore_fn_func_sign_in(
853
- FfiConverterString.lower(secretKey),$0)
854
- }
925
+ FfiConverterString.lower(secretKey),$0
855
926
  )
927
+ })
856
928
  }
857
-
858
- public func signOut(secretKey: String) -> [String] {
859
- return try! FfiConverterSequenceString.lift(
860
- try! rustCall() {
929
+ public func signOut(sessionSecret: String) -> [String] {
930
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
861
931
  uniffi_pubkycore_fn_func_sign_out(
862
- FfiConverterString.lower(secretKey),$0)
863
- }
932
+ FfiConverterString.lower(sessionSecret),$0
864
933
  )
934
+ })
865
935
  }
866
-
867
- public func signUp(secretKey: String, homeserver: String, signupToken: String?) -> [String] {
868
- return try! FfiConverterSequenceString.lift(
869
- try! rustCall() {
936
+ public func signUp(secretKey: String, homeserver: String, signupToken: String?) -> [String] {
937
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
870
938
  uniffi_pubkycore_fn_func_sign_up(
871
939
  FfiConverterString.lower(secretKey),
872
940
  FfiConverterString.lower(homeserver),
873
- FfiConverterOptionString.lower(signupToken),$0)
874
- }
941
+ FfiConverterOptionString.lower(signupToken),$0
875
942
  )
943
+ })
876
944
  }
877
-
878
- public func switchNetwork(useTestnet: Bool) -> [String] {
879
- return try! FfiConverterSequenceString.lift(
880
- try! rustCall() {
945
+ public func switchNetwork(useTestnet: Bool) -> [String] {
946
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
881
947
  uniffi_pubkycore_fn_func_switch_network(
882
- FfiConverterBool.lower(useTestnet),$0)
883
- }
948
+ FfiConverterBool.lower(useTestnet),$0
884
949
  )
950
+ })
885
951
  }
886
-
887
- public func validateMnemonicPhrase(mnemonicPhrase: String) -> [String] {
888
- return try! FfiConverterSequenceString.lift(
889
- try! rustCall() {
952
+ public func validateMnemonicPhrase(mnemonicPhrase: String) -> [String] {
953
+ return try! FfiConverterSequenceString.lift(try! rustCall() {
890
954
  uniffi_pubkycore_fn_func_validate_mnemonic_phrase(
891
- FfiConverterString.lower(mnemonicPhrase),$0)
892
- }
955
+ FfiConverterString.lower(mnemonicPhrase),$0
893
956
  )
957
+ })
894
958
  }
895
959
 
896
960
  private enum InitializationResult {
@@ -898,108 +962,111 @@ private enum InitializationResult {
898
962
  case contractVersionMismatch
899
963
  case apiChecksumMismatch
900
964
  }
901
- // Use a global variables to perform the versioning checks. Swift ensures that
965
+ // Use a global variable to perform the versioning checks. Swift ensures that
902
966
  // the code inside is only computed once.
903
- private var initializationResult: InitializationResult {
967
+ private let initializationResult: InitializationResult = {
904
968
  // Get the bindings contract version from our ComponentInterface
905
- let bindings_contract_version = 24
969
+ let bindings_contract_version = 29
906
970
  // Get the scaffolding contract version by calling the into the dylib
907
971
  let scaffolding_contract_version = ffi_pubkycore_uniffi_contract_version()
908
972
  if bindings_contract_version != scaffolding_contract_version {
909
973
  return InitializationResult.contractVersionMismatch
910
974
  }
911
- if (uniffi_pubkycore_checksum_func_auth() != 51826) {
975
+ if (uniffi_pubkycore_checksum_func_auth() != 36598) {
912
976
  return InitializationResult.apiChecksumMismatch
913
977
  }
914
- if (uniffi_pubkycore_checksum_func_create_recovery_file() != 48846) {
978
+ if (uniffi_pubkycore_checksum_func_create_recovery_file() != 13366) {
915
979
  return InitializationResult.apiChecksumMismatch
916
980
  }
917
- if (uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 26407) {
981
+ if (uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 56578) {
918
982
  return InitializationResult.apiChecksumMismatch
919
983
  }
920
- if (uniffi_pubkycore_checksum_func_delete_file() != 9063) {
984
+ if (uniffi_pubkycore_checksum_func_delete_file() != 37648) {
921
985
  return InitializationResult.apiChecksumMismatch
922
986
  }
923
- if (uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() != 2358) {
987
+ if (uniffi_pubkycore_checksum_func_generate_mnemonic_phrase() != 38398) {
924
988
  return InitializationResult.apiChecksumMismatch
925
989
  }
926
- if (uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() != 44395) {
990
+ if (uniffi_pubkycore_checksum_func_generate_mnemonic_phrase_and_keypair() != 13119) {
927
991
  return InitializationResult.apiChecksumMismatch
928
992
  }
929
- if (uniffi_pubkycore_checksum_func_generate_secret_key() != 12800) {
993
+ if (uniffi_pubkycore_checksum_func_generate_secret_key() != 63319) {
930
994
  return InitializationResult.apiChecksumMismatch
931
995
  }
932
- if (uniffi_pubkycore_checksum_func_get() != 6591) {
996
+ if (uniffi_pubkycore_checksum_func_get() != 12463) {
933
997
  return InitializationResult.apiChecksumMismatch
934
998
  }
935
- if (uniffi_pubkycore_checksum_func_get_homeserver() != 40658) {
999
+ if (uniffi_pubkycore_checksum_func_get_homeserver() != 35947) {
936
1000
  return InitializationResult.apiChecksumMismatch
937
1001
  }
938
- if (uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 40316) {
1002
+ if (uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 65274) {
939
1003
  return InitializationResult.apiChecksumMismatch
940
1004
  }
941
- if (uniffi_pubkycore_checksum_func_get_signup_token() != 47927) {
1005
+ if (uniffi_pubkycore_checksum_func_get_signup_token() != 7931) {
942
1006
  return InitializationResult.apiChecksumMismatch
943
1007
  }
944
- if (uniffi_pubkycore_checksum_func_list() != 43198) {
1008
+ if (uniffi_pubkycore_checksum_func_list() != 14351) {
945
1009
  return InitializationResult.apiChecksumMismatch
946
1010
  }
947
- if (uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() != 45784) {
1011
+ if (uniffi_pubkycore_checksum_func_mnemonic_phrase_to_keypair() != 59088) {
948
1012
  return InitializationResult.apiChecksumMismatch
949
1013
  }
950
- if (uniffi_pubkycore_checksum_func_parse_auth_url() != 27379) {
1014
+ if (uniffi_pubkycore_checksum_func_parse_auth_url() != 47180) {
951
1015
  return InitializationResult.apiChecksumMismatch
952
1016
  }
953
- if (uniffi_pubkycore_checksum_func_publish() != 48989) {
1017
+ if (uniffi_pubkycore_checksum_func_publish() != 60897) {
954
1018
  return InitializationResult.apiChecksumMismatch
955
1019
  }
956
- if (uniffi_pubkycore_checksum_func_publish_https() != 5614) {
1020
+ if (uniffi_pubkycore_checksum_func_publish_https() != 43863) {
957
1021
  return InitializationResult.apiChecksumMismatch
958
1022
  }
959
- if (uniffi_pubkycore_checksum_func_put() != 48150) {
1023
+ if (uniffi_pubkycore_checksum_func_put() != 29897) {
960
1024
  return InitializationResult.apiChecksumMismatch
961
1025
  }
962
- if (uniffi_pubkycore_checksum_func_remove_event_listener() != 23534) {
1026
+ if (uniffi_pubkycore_checksum_func_remove_event_listener() != 3828) {
963
1027
  return InitializationResult.apiChecksumMismatch
964
1028
  }
965
- if (uniffi_pubkycore_checksum_func_republish_homeserver() != 63919) {
1029
+ if (uniffi_pubkycore_checksum_func_republish_homeserver() != 20001) {
966
1030
  return InitializationResult.apiChecksumMismatch
967
1031
  }
968
- if (uniffi_pubkycore_checksum_func_resolve() != 34317) {
1032
+ if (uniffi_pubkycore_checksum_func_resolve() != 873) {
969
1033
  return InitializationResult.apiChecksumMismatch
970
1034
  }
971
- if (uniffi_pubkycore_checksum_func_resolve_https() != 17266) {
1035
+ if (uniffi_pubkycore_checksum_func_resolve_https() != 34852) {
972
1036
  return InitializationResult.apiChecksumMismatch
973
1037
  }
974
- if (uniffi_pubkycore_checksum_func_session() != 59795) {
1038
+ if (uniffi_pubkycore_checksum_func_revalidate_session() != 12593) {
975
1039
  return InitializationResult.apiChecksumMismatch
976
1040
  }
977
- if (uniffi_pubkycore_checksum_func_set_event_listener() != 60071) {
1041
+ if (uniffi_pubkycore_checksum_func_set_event_listener() != 18894) {
978
1042
  return InitializationResult.apiChecksumMismatch
979
1043
  }
980
- if (uniffi_pubkycore_checksum_func_sign_in() != 21584) {
1044
+ if (uniffi_pubkycore_checksum_func_sign_in() != 31244) {
981
1045
  return InitializationResult.apiChecksumMismatch
982
1046
  }
983
- if (uniffi_pubkycore_checksum_func_sign_out() != 34903) {
1047
+ if (uniffi_pubkycore_checksum_func_sign_out() != 9048) {
984
1048
  return InitializationResult.apiChecksumMismatch
985
1049
  }
986
- if (uniffi_pubkycore_checksum_func_sign_up() != 48789) {
1050
+ if (uniffi_pubkycore_checksum_func_sign_up() != 49409) {
987
1051
  return InitializationResult.apiChecksumMismatch
988
1052
  }
989
- if (uniffi_pubkycore_checksum_func_switch_network() != 64215) {
1053
+ if (uniffi_pubkycore_checksum_func_switch_network() != 48346) {
990
1054
  return InitializationResult.apiChecksumMismatch
991
1055
  }
992
- if (uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() != 30362) {
1056
+ if (uniffi_pubkycore_checksum_func_validate_mnemonic_phrase() != 9633) {
993
1057
  return InitializationResult.apiChecksumMismatch
994
1058
  }
995
- if (uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 11531) {
1059
+ if (uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 24359) {
996
1060
  return InitializationResult.apiChecksumMismatch
997
1061
  }
998
1062
 
1063
+ uniffiCallbackInitEventListener()
999
1064
  return InitializationResult.ok
1000
- }
1065
+ }()
1001
1066
 
1002
- private func uniffiEnsureInitialized() {
1067
+ // Make the ensure init function public so that other modules which have external type references to
1068
+ // our types can call it.
1069
+ public func uniffiEnsurePubkycoreInitialized() {
1003
1070
  switch initializationResult {
1004
1071
  case .ok:
1005
1072
  break
@@ -1008,4 +1075,6 @@ private func uniffiEnsureInitialized() {
1008
1075
  case .apiChecksumMismatch:
1009
1076
  fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1010
1077
  }
1011
- }
1078
+ }
1079
+
1080
+ // swiftlint:enable all