sdk

Radroots SDK and bindings
git clone https://radroots.dev/git/sdk.git
Log | Files | Refs | README

radroots_sdk.swift (65780B)


      1 // This file was autogenerated by some hot garbage in the `uniffi` crate.
      2 // Trust me, you don't want to mess with it!
      3 
      4 // swiftlint:disable all
      5 import Foundation
      6 
      7 // Depending on the consumer's build setup, the low-level FFI code
      8 // might be in a separate module, or it might be compiled inline into
      9 // this module. This is a bit of light hackery to work with both.
     10 #if canImport(radroots_sdkFFI)
     11 import radroots_sdkFFI
     12 #endif
     13 
     14 fileprivate extension RustBuffer {
     15     // Allocate a new buffer, copying the contents of a `UInt8` array.
     16     init(bytes: [UInt8]) {
     17         let rbuf = bytes.withUnsafeBufferPointer { ptr in
     18             RustBuffer.from(ptr)
     19         }
     20         self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
     21     }
     22 
     23     static func empty() -> RustBuffer {
     24         RustBuffer(capacity: 0, len:0, data: nil)
     25     }
     26 
     27     static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
     28         try! rustCall { ffi_radroots_sdk_ffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
     29     }
     30 
     31     // Frees the buffer in place.
     32     // The buffer must not be used after this is called.
     33     func deallocate() {
     34         try! rustCall { ffi_radroots_sdk_ffi_rustbuffer_free(self, $0) }
     35     }
     36 }
     37 
     38 fileprivate extension ForeignBytes {
     39     init(bufferPointer: UnsafeBufferPointer<UInt8>) {
     40         self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
     41     }
     42 
     43     init(rawBufferPointer: UnsafeRawBufferPointer) {
     44         self.init(
     45             len: Int32(rawBufferPointer.count),
     46             data: rawBufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self)
     47         )
     48     }
     49 }
     50 
     51 // Converter for `&[u8]` / `[ByRef] bytes` arguments.
     52 //
     53 // Conforms to `FfiConverter` so the compiler enforces the full converter
     54 // method set. Only the scope-bound `lower(_:_body:)` overload is sound —
     55 // zero-copy byte buffers only flow foreign -> Rust, and only in argument
     56 // position. The four protocol-witness methods (`lift`, `lower`, `read`,
     57 // `write`) `fatalError` at runtime if anyone reaches them.
     58 //
     59 // The scope-bound `lower` takes a closure because the `ForeignBytes`
     60 // pointer is only guaranteed valid for the duration of
     61 // `Data.withUnsafeBytes`. Callers must run the full FFI call inside
     62 // the closure body.
     63 fileprivate enum FfiConverterByRefBytes: FfiConverter {
     64     typealias SwiftType = Data
     65     typealias FfiType = ForeignBytes
     66 
     67     static func lower<R>(_ value: Data, _ body: (ForeignBytes) throws -> R) rethrows -> R {
     68         return try value.withUnsafeBytes { rawBuf in
     69             try body(ForeignBytes(rawBufferPointer: rawBuf))
     70         }
     71     }
     72 
     73     static func lower(_ value: Data) -> ForeignBytes {
     74         fatalError("ByRef bytes cannot use the plain lower: returning ForeignBytes escapes the Data.withUnsafeBytes scope. Use the scope-bound lower(_:_body:) overload instead.")
     75     }
     76 
     77     static func lift(_ value: ForeignBytes) throws -> Data {
     78         fatalError("ByRef bytes cannot be lifted: zero-copy &[u8] only flows foreign->Rust")
     79     }
     80 
     81     static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
     82         fatalError("ByRef bytes cannot be read from a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
     83     }
     84 
     85     static func write(_ value: Data, into buf: inout [UInt8]) {
     86         fatalError("ByRef bytes cannot be written to a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
     87     }
     88 }
     89 
     90 // For every type used in the interface, we provide helper methods for conveniently
     91 // lifting and lowering that type from C-compatible data, and for reading and writing
     92 // values of that type in a buffer.
     93 
     94 // Helper classes/extensions that don't change.
     95 // Someday, this will be in a library of its own.
     96 
     97 fileprivate extension Data {
     98     init(rustBuffer: RustBuffer) {
     99         self.init(
    100             bytesNoCopy: rustBuffer.data!,
    101             count: Int(rustBuffer.len),
    102             deallocator: .none
    103         )
    104     }
    105 }
    106 
    107 // Define reader functionality.  Normally this would be defined in a class or
    108 // struct, but we use standalone functions instead in order to make external
    109 // types work.
    110 //
    111 // With external types, one swift source file needs to be able to call the read
    112 // method on another source file's FfiConverter, but then what visibility
    113 // should Reader have?
    114 // - If Reader is fileprivate, then this means the read() must also
    115 //   be fileprivate, which doesn't work with external types.
    116 // - If Reader is internal/public, we'll get compile errors since both source
    117 //   files will try define the same type.
    118 //
    119 // Instead, the read() method and these helper functions input a tuple of data
    120 
    121 fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
    122     (data: data, offset: 0)
    123 }
    124 
    125 // Reads an integer at the current offset, in big-endian order, and advances
    126 // the offset on success. Throws if reading the integer would move the
    127 // offset past the end of the buffer.
    128 fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
    129     let range = reader.offset..<reader.offset + MemoryLayout<T>.size
    130     guard reader.data.count >= range.upperBound else {
    131         throw UniffiInternalError.bufferOverflow
    132     }
    133     if T.self == UInt8.self {
    134         let value = reader.data[reader.offset]
    135         reader.offset += 1
    136         return value as! T
    137     }
    138     var value: T = 0
    139     let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
    140     reader.offset = range.upperBound
    141     return value.bigEndian
    142 }
    143 
    144 // Reads an arbitrary number of bytes, to be used to read
    145 // raw bytes, this is useful when lifting strings
    146 fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
    147     let range = reader.offset..<(reader.offset+count)
    148     guard reader.data.count >= range.upperBound else {
    149         throw UniffiInternalError.bufferOverflow
    150     }
    151     var value = [UInt8](repeating: 0, count: count)
    152     value.withUnsafeMutableBufferPointer({ buffer in
    153         reader.data.copyBytes(to: buffer, from: range)
    154     })
    155     reader.offset = range.upperBound
    156     return value
    157 }
    158 
    159 // Reads a float at the current offset.
    160 fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
    161     return Float(bitPattern: try readInt(&reader))
    162 }
    163 
    164 // Reads a float at the current offset.
    165 fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
    166     return Double(bitPattern: try readInt(&reader))
    167 }
    168 
    169 // Indicates if the offset has reached the end of the buffer.
    170 fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
    171     return reader.offset < reader.data.count
    172 }
    173 
    174 // Define writer functionality.  Normally this would be defined in a class or
    175 // struct, but we use standalone functions instead in order to make external
    176 // types work.  See the above discussion on Readers for details.
    177 
    178 fileprivate func createWriter() -> [UInt8] {
    179     return []
    180 }
    181 
    182 fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
    183     writer.append(contentsOf: byteArr)
    184 }
    185 
    186 // Writes an integer in big-endian order.
    187 //
    188 // Warning: make sure what you are trying to write
    189 // is in the correct type!
    190 fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
    191     var value = value.bigEndian
    192     withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
    193 }
    194 
    195 fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
    196     writeInt(&writer, value.bitPattern)
    197 }
    198 
    199 fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
    200     writeInt(&writer, value.bitPattern)
    201 }
    202 
    203 // Protocol for types that transfer other types across the FFI. This is
    204 // analogous to the Rust trait of the same name.
    205 fileprivate protocol FfiConverter {
    206     associatedtype FfiType
    207     associatedtype SwiftType
    208 
    209     static func lift(_ value: FfiType) throws -> SwiftType
    210     static func lower(_ value: SwiftType) -> FfiType
    211     static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
    212     static func write(_ value: SwiftType, into buf: inout [UInt8])
    213 }
    214 
    215 // Types conforming to `Primitive` pass themselves directly over the FFI.
    216 fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
    217 
    218 extension FfiConverterPrimitive {
    219 #if swift(>=5.8)
    220     @_documentation(visibility: private)
    221 #endif
    222     public static func lift(_ value: FfiType) throws -> SwiftType {
    223         return value
    224     }
    225 
    226 #if swift(>=5.8)
    227     @_documentation(visibility: private)
    228 #endif
    229     public static func lower(_ value: SwiftType) -> FfiType {
    230         return value
    231     }
    232 }
    233 
    234 // Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
    235 // Used for complex types where it's hard to write a custom lift/lower.
    236 fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
    237 
    238 extension FfiConverterRustBuffer {
    239 #if swift(>=5.8)
    240     @_documentation(visibility: private)
    241 #endif
    242     public static func lift(_ buf: RustBuffer) throws -> SwiftType {
    243         var reader = createReader(data: Data(rustBuffer: buf))
    244         let value = try read(from: &reader)
    245         if hasRemaining(reader) {
    246             throw UniffiInternalError.incompleteData
    247         }
    248         buf.deallocate()
    249         return value
    250     }
    251 
    252 #if swift(>=5.8)
    253     @_documentation(visibility: private)
    254 #endif
    255     public static func lower(_ value: SwiftType) -> RustBuffer {
    256           var writer = createWriter()
    257           write(value, into: &writer)
    258           return RustBuffer(bytes: writer)
    259     }
    260 }
    261 // An error type for FFI errors. These errors occur at the UniFFI level, not
    262 // the library level.
    263 fileprivate enum UniffiInternalError: LocalizedError {
    264     case bufferOverflow
    265     case incompleteData
    266     case unexpectedOptionalTag
    267     case unexpectedEnumCase
    268     case unexpectedNullPointer
    269     case unexpectedRustCallStatusCode
    270     case unexpectedRustCallError
    271     case unexpectedStaleHandle
    272     case rustPanic(_ message: String)
    273 
    274     public var errorDescription: String? {
    275         switch self {
    276         case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
    277         case .incompleteData: return "The buffer still has data after lifting its containing value"
    278         case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
    279         case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
    280         case .unexpectedNullPointer: return "Raw pointer value was null"
    281         case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
    282         case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
    283         case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
    284         case let .rustPanic(message): return message
    285         }
    286     }
    287 }
    288 
    289 fileprivate extension NSLock {
    290     func withLock<T>(f: () throws -> T) rethrows -> T {
    291         self.lock()
    292         defer { self.unlock() }
    293         return try f()
    294     }
    295 }
    296 
    297 fileprivate let CALL_SUCCESS: Int8 = 0
    298 fileprivate let CALL_ERROR: Int8 = 1
    299 fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
    300 fileprivate let CALL_CANCELLED: Int8 = 3
    301 
    302 fileprivate extension RustCallStatus {
    303     init() {
    304         self.init(
    305             code: CALL_SUCCESS,
    306             errorBuf: RustBuffer.init(
    307                 capacity: 0,
    308                 len: 0,
    309                 data: nil
    310             )
    311         )
    312     }
    313 }
    314 
    315 private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
    316     let neverThrow: ((RustBuffer) throws -> Never)? = nil
    317     return try makeRustCall(callback, errorHandler: neverThrow)
    318 }
    319 
    320 private func rustCallWithError<T, E: Swift.Error>(
    321     _ errorHandler: @escaping (RustBuffer) throws -> E,
    322     _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
    323     try makeRustCall(callback, errorHandler: errorHandler)
    324 }
    325 
    326 private func makeRustCall<T, E: Swift.Error>(
    327     _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
    328     errorHandler: ((RustBuffer) throws -> E)?
    329 ) throws -> T {
    330     uniffiEnsureRadrootsSdkFfiInitialized()
    331     var callStatus = RustCallStatus.init()
    332     let returnedVal = callback(&callStatus)
    333     try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
    334     return returnedVal
    335 }
    336 
    337 private func uniffiCheckCallStatus<E: Swift.Error>(
    338     callStatus: RustCallStatus,
    339     errorHandler: ((RustBuffer) throws -> E)?
    340 ) throws {
    341     switch callStatus.code {
    342         case CALL_SUCCESS:
    343             return
    344 
    345         case CALL_ERROR:
    346             if let errorHandler = errorHandler {
    347                 throw try errorHandler(callStatus.errorBuf)
    348             } else {
    349                 callStatus.errorBuf.deallocate()
    350                 throw UniffiInternalError.unexpectedRustCallError
    351             }
    352 
    353         case CALL_UNEXPECTED_ERROR:
    354             // When the rust code sees a panic, it tries to construct a RustBuffer
    355             // with the message.  But if that code panics, then it just sends back
    356             // an empty buffer.
    357             if callStatus.errorBuf.len > 0 {
    358                 throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
    359             } else {
    360                 callStatus.errorBuf.deallocate()
    361                 throw UniffiInternalError.rustPanic("Rust panic")
    362             }
    363 
    364         case CALL_CANCELLED:
    365             throw CancellationError()
    366 
    367         default:
    368             throw UniffiInternalError.unexpectedRustCallStatusCode
    369     }
    370 }
    371 
    372 private func uniffiTraitInterfaceCall<T>(
    373     callStatus: UnsafeMutablePointer<RustCallStatus>,
    374     makeCall: () throws -> T,
    375     writeReturn: (T) -> ()
    376 ) {
    377     do {
    378         try writeReturn(makeCall())
    379     } catch let error {
    380         callStatus.pointee.code = CALL_UNEXPECTED_ERROR
    381         callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
    382     }
    383 }
    384 
    385 private func uniffiTraitInterfaceCallWithError<T, E>(
    386     callStatus: UnsafeMutablePointer<RustCallStatus>,
    387     makeCall: () throws -> T,
    388     writeReturn: (T) -> (),
    389     lowerError: (E) -> RustBuffer
    390 ) {
    391     do {
    392         try writeReturn(makeCall())
    393     } catch let error as E {
    394         callStatus.pointee.code = CALL_ERROR
    395         callStatus.pointee.errorBuf = lowerError(error)
    396     } catch {
    397         callStatus.pointee.code = CALL_UNEXPECTED_ERROR
    398         callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
    399     }
    400 }
    401 // Initial value and increment amount for handles.
    402 // These ensure that SWIFT handles always have the lowest bit set
    403 fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1
    404 fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2
    405 
    406 fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
    407     // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
    408     private let lock = NSLock()
    409     private var map: [UInt64: T] = [:]
    410     private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL
    411 
    412     func insert(obj: T) -> UInt64 {
    413         lock.withLock {
    414             return doInsert(obj)
    415         }
    416     }
    417 
    418     // Low-level insert function, this assumes `lock` is held.
    419     private func doInsert(_ obj: T) -> UInt64 {
    420         let handle = currentHandle
    421         currentHandle += UNIFFI_HANDLEMAP_DELTA
    422         map[handle] = obj
    423         return handle
    424     }
    425 
    426      func get(handle: UInt64) throws -> T {
    427         try lock.withLock {
    428             guard let obj = map[handle] else {
    429                 throw UniffiInternalError.unexpectedStaleHandle
    430             }
    431             return obj
    432         }
    433     }
    434 
    435      func clone(handle: UInt64) throws -> UInt64 {
    436         try lock.withLock {
    437             guard let obj = map[handle] else {
    438                 throw UniffiInternalError.unexpectedStaleHandle
    439             }
    440             return doInsert(obj)
    441         }
    442     }
    443 
    444     @discardableResult
    445     func remove(handle: UInt64) throws -> T {
    446         try lock.withLock {
    447             guard let obj = map.removeValue(forKey: handle) else {
    448                 throw UniffiInternalError.unexpectedStaleHandle
    449             }
    450             return obj
    451         }
    452     }
    453 
    454     var count: Int {
    455         get {
    456             map.count
    457         }
    458     }
    459 }
    460 
    461 
    462 // Public interface members begin here.
    463 
    464 
    465 #if swift(>=5.8)
    466 @_documentation(visibility: private)
    467 #endif
    468 fileprivate struct FfiConverterUInt16: FfiConverterPrimitive {
    469     typealias FfiType = UInt16
    470     typealias SwiftType = UInt16
    471 
    472     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 {
    473         return try lift(readInt(&buf))
    474     }
    475 
    476     public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
    477         writeInt(&buf, lower(value))
    478     }
    479 }
    480 
    481 #if swift(>=5.8)
    482 @_documentation(visibility: private)
    483 #endif
    484 fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
    485     typealias FfiType = UInt32
    486     typealias SwiftType = UInt32
    487 
    488     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
    489         return try lift(readInt(&buf))
    490     }
    491 
    492     public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
    493         writeInt(&buf, lower(value))
    494     }
    495 }
    496 
    497 #if swift(>=5.8)
    498 @_documentation(visibility: private)
    499 #endif
    500 fileprivate struct FfiConverterUInt64: FfiConverterPrimitive {
    501     typealias FfiType = UInt64
    502     typealias SwiftType = UInt64
    503 
    504     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
    505         return try lift(readInt(&buf))
    506     }
    507 
    508     public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
    509         writeInt(&buf, lower(value))
    510     }
    511 }
    512 
    513 #if swift(>=5.8)
    514 @_documentation(visibility: private)
    515 #endif
    516 fileprivate struct FfiConverterBool : FfiConverter {
    517     typealias FfiType = Int8
    518     typealias SwiftType = Bool
    519 
    520     public static func lift(_ value: Int8) throws -> Bool {
    521         return value != 0
    522     }
    523 
    524     public static func lower(_ value: Bool) -> Int8 {
    525         return value ? 1 : 0
    526     }
    527 
    528     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
    529         return try lift(readInt(&buf))
    530     }
    531 
    532     public static func write(_ value: Bool, into buf: inout [UInt8]) {
    533         writeInt(&buf, lower(value))
    534     }
    535 }
    536 
    537 #if swift(>=5.8)
    538 @_documentation(visibility: private)
    539 #endif
    540 fileprivate struct FfiConverterString: FfiConverter {
    541     typealias SwiftType = String
    542     typealias FfiType = RustBuffer
    543 
    544     public static func lift(_ value: RustBuffer) throws -> String {
    545         defer {
    546             value.deallocate()
    547         }
    548         if value.data == nil {
    549             return String()
    550         }
    551         let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
    552         // Use Swift's native UTF-8 decoder; `String(bytes:encoding:.utf8)` goes
    553         // through Foundation's NSString and silently strips a leading U+FEFF BOM.
    554         // Invalid UTF-8 substitutes U+FFFD instead of trapping (unreachable
    555         // given Rust's `String` invariant).
    556         return String(decoding: bytes, as: UTF8.self)
    557     }
    558 
    559     public static func lower(_ value: String) -> RustBuffer {
    560         return value.utf8CString.withUnsafeBufferPointer { ptr in
    561             // The swift string gives us int8_t, we want uint8_t.
    562             ptr.withMemoryRebound(to: UInt8.self) { ptr in
    563                 // The swift string gives us a trailing null byte, we don't want it.
    564                 let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
    565                 return RustBuffer.from(buf)
    566             }
    567         }
    568     }
    569 
    570     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
    571         let len: Int32 = try readInt(&buf)
    572         // See `lift` above for why we avoid Foundation's NSString-backed decoder here.
    573         return String(decoding: try readBytes(&buf, count: Int(len)), as: UTF8.self)
    574     }
    575 
    576     public static func write(_ value: String, into buf: inout [UInt8]) {
    577         let len = Int32(value.utf8.count)
    578         writeInt(&buf, len)
    579         writeBytes(&buf, value.utf8)
    580     }
    581 }
    582 
    583 #if swift(>=5.8)
    584 @_documentation(visibility: private)
    585 #endif
    586 fileprivate struct FfiConverterData: FfiConverterRustBuffer {
    587     typealias SwiftType = Data
    588 
    589     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
    590         let len: Int32 = try readInt(&buf)
    591         return Data(try readBytes(&buf, count: Int(len)))
    592     }
    593 
    594     public static func write(_ value: Data, into buf: inout [UInt8]) {
    595         let len = Int32(value.count)
    596         writeInt(&buf, len)
    597         writeBytes(&buf, value)
    598     }
    599 }
    600 
    601 
    602 
    603 
    604 /**
    605  * Thread-safe mobile handle delegating lifecycle to [`radroots_sdk::Client`].
    606  */
    607 public protocol MobileClientProtocol: AnyObject, Sendable {
    608 
    609     /**
    610      * Returns stable capability DTOs without probing host resources.
    611      */
    612     func capabilities()  -> [CapabilityStatus]
    613 
    614     /**
    615      * Explicitly closes SDK-owned resources without installing a runtime.
    616      */
    617     func close() async throws
    618 
    619     /**
    620      * Returns whether explicit SDK close completed across all clones.
    621      */
    622     func isClosed()  -> Bool
    623 
    624 }
    625 /**
    626  * Thread-safe mobile handle delegating lifecycle to [`radroots_sdk::Client`].
    627  */
    628 open class MobileClient: MobileClientProtocol, @unchecked Sendable {
    629     fileprivate let handle: UInt64
    630 
    631     /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
    632 #if swift(>=5.8)
    633     @_documentation(visibility: private)
    634 #endif
    635     public struct NoHandle {
    636         public init() {}
    637     }
    638 
    639     // TODO: We'd like this to be `private` but for Swifty reasons,
    640     // we can't implement `FfiConverter` without making this `required` and we can't
    641     // make it `required` without making it `public`.
    642 #if swift(>=5.8)
    643     @_documentation(visibility: private)
    644 #endif
    645     required public init(unsafeFromHandle handle: UInt64) {
    646         self.handle = handle
    647     }
    648 
    649     // This constructor can be used to instantiate a fake object.
    650     // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
    651     //
    652     // - Warning:
    653     //     Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
    654 #if swift(>=5.8)
    655     @_documentation(visibility: private)
    656 #endif
    657     public init(noHandle: NoHandle) {
    658         self.handle = 0
    659     }
    660 
    661 #if swift(>=5.8)
    662     @_documentation(visibility: private)
    663 #endif
    664     public func uniffiCloneHandle() -> UInt64 {
    665         return try! rustCall { uniffi_radroots_sdk_ffi_fn_clone_mobileclient(self.handle, $0) }
    666     }
    667     // No primary constructor declared for this class.
    668 
    669     deinit {
    670         if handle == 0 {
    671             // Mock objects have handle=0 don't try to free them
    672             return
    673         }
    674 
    675         try! rustCall { uniffi_radroots_sdk_ffi_fn_free_mobileclient(handle, $0) }
    676     }
    677 
    678 
    679     /**
    680      * Creates a deterministic, local-only memory client without I/O.
    681      */
    682 public static func memory()throws  -> MobileClient  {
    683     return try  FfiConverterTypeMobileClient_lift(try rustCallWithError(FfiConverterTypeError_lift) {
    684         uniffiCallStatus in
    685     uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(uniffiCallStatus
    686     )
    687 })
    688 }
    689 
    690 
    691 
    692     /**
    693      * Returns stable capability DTOs without probing host resources.
    694      */
    695 open func capabilities() -> [CapabilityStatus]  {
    696     return try!  FfiConverterSequenceTypeCapabilityStatus.lift(try! rustCall() {
    697         uniffiCallStatus in
    698     uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(
    699             self.uniffiCloneHandle(),uniffiCallStatus
    700     )
    701 })
    702 }
    703 
    704     /**
    705      * Explicitly closes SDK-owned resources without installing a runtime.
    706      */
    707 open func close()async throws   {
    708     return
    709         try  await uniffiRustCallAsync(
    710             rustFutureFunc: {
    711                 uniffi_radroots_sdk_ffi_fn_method_mobileclient_close(
    712                         self.uniffiCloneHandle()
    713                 )
    714             },
    715             pollFunc: ffi_radroots_sdk_ffi_rust_future_poll_void,
    716             completeFunc: ffi_radroots_sdk_ffi_rust_future_complete_void,
    717             cancelFunc: ffi_radroots_sdk_ffi_rust_future_cancel_void,
    718             freeFunc: ffi_radroots_sdk_ffi_rust_future_free_void,
    719             liftFunc: { $0 },
    720             errorHandler: FfiConverterTypeError_lift
    721         )
    722 }
    723 
    724     /**
    725      * Returns whether explicit SDK close completed across all clones.
    726      */
    727 open func isClosed() -> Bool  {
    728     return try!  FfiConverterBool.lift(try! rustCall() {
    729         uniffiCallStatus in
    730     uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(
    731             self.uniffiCloneHandle(),uniffiCallStatus
    732     )
    733 })
    734 }
    735 
    736 
    737 
    738 }
    739 
    740 
    741 #if swift(>=5.8)
    742 @_documentation(visibility: private)
    743 #endif
    744 public struct FfiConverterTypeMobileClient: FfiConverter {
    745     typealias FfiType = UInt64
    746     typealias SwiftType = MobileClient
    747 
    748     public static func lift(_ handle: UInt64) throws -> MobileClient {
    749         return MobileClient(unsafeFromHandle: handle)
    750     }
    751 
    752     public static func lower(_ value: MobileClient) -> UInt64 {
    753         return value.uniffiCloneHandle()
    754     }
    755 
    756     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MobileClient {
    757         let handle: UInt64 = try readInt(&buf)
    758         return try lift(handle)
    759     }
    760 
    761     public static func write(_ value: MobileClient, into buf: inout [UInt8]) {
    762         writeInt(&buf, lower(value))
    763     }
    764 }
    765 
    766 
    767 #if swift(>=5.8)
    768 @_documentation(visibility: private)
    769 #endif
    770 public func FfiConverterTypeMobileClient_lift(_ handle: UInt64) throws -> MobileClient {
    771     return try FfiConverterTypeMobileClient.lift(handle)
    772 }
    773 
    774 #if swift(>=5.8)
    775 @_documentation(visibility: private)
    776 #endif
    777 public func FfiConverterTypeMobileClient_lower(_ value: MobileClient) -> UInt64 {
    778     return FfiConverterTypeMobileClient.lower(value)
    779 }
    780 
    781 
    782 
    783 
    784 /**
    785  * Versioned, presentation-independent capability observation.
    786  */
    787 public struct CapabilityStatus: Equatable, Hashable {
    788     public var id: String
    789     public var compiled: Bool
    790     public var configured: Bool
    791     public var availability: CapabilityAvailability
    792     public var maturity: CapabilityMaturity
    793 
    794     // Default memberwise initializers are never public by default, so we
    795     // declare one manually.
    796     public init(id: String, compiled: Bool, configured: Bool, availability: CapabilityAvailability, maturity: CapabilityMaturity) {
    797         self.id = id
    798         self.compiled = compiled
    799         self.configured = configured
    800         self.availability = availability
    801         self.maturity = maturity
    802     }
    803 
    804 
    805 
    806 
    807 }
    808 
    809 #if compiler(>=6)
    810 extension CapabilityStatus: Sendable {}
    811 #endif
    812 
    813 #if swift(>=5.8)
    814 @_documentation(visibility: private)
    815 #endif
    816 public struct FfiConverterTypeCapabilityStatus: FfiConverterRustBuffer {
    817     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CapabilityStatus {
    818         return
    819             try CapabilityStatus(
    820                 id: FfiConverterString.read(from: &buf),
    821                 compiled: FfiConverterBool.read(from: &buf),
    822                 configured: FfiConverterBool.read(from: &buf),
    823                 availability: FfiConverterTypeCapabilityAvailability.read(from: &buf),
    824                 maturity: FfiConverterTypeCapabilityMaturity.read(from: &buf)
    825         )
    826     }
    827 
    828     public static func write(_ value: CapabilityStatus, into buf: inout [UInt8]) {
    829         FfiConverterString.write(value.id, into: &buf)
    830         FfiConverterBool.write(value.compiled, into: &buf)
    831         FfiConverterBool.write(value.configured, into: &buf)
    832         FfiConverterTypeCapabilityAvailability.write(value.availability, into: &buf)
    833         FfiConverterTypeCapabilityMaturity.write(value.maturity, into: &buf)
    834     }
    835 }
    836 
    837 
    838 #if swift(>=5.8)
    839 @_documentation(visibility: private)
    840 #endif
    841 public func FfiConverterTypeCapabilityStatus_lift(_ buf: RustBuffer) throws -> CapabilityStatus {
    842     return try FfiConverterTypeCapabilityStatus.lift(buf)
    843 }
    844 
    845 #if swift(>=5.8)
    846 @_documentation(visibility: private)
    847 #endif
    848 public func FfiConverterTypeCapabilityStatus_lower(_ value: CapabilityStatus) -> RustBuffer {
    849     return FfiConverterTypeCapabilityStatus.lower(value)
    850 }
    851 
    852 
    853 /**
    854  * Verified final RHI attestation projection.
    855  */
    856 public struct RhiEvidenceAttestation: Equatable, Hashable {
    857     public var issuerPubkey: String
    858     public var tradeId: String
    859     public var claimMutationId: String
    860     public var outcome: TradeEvidenceOutcome
    861     public var observedAtUnixS: String
    862     public var tradeGeneration: String
    863     public var statementDigest: String
    864     public var supersession: RhiEvidenceSupersession?
    865     public var canonicalContent: String
    866 
    867     // Default memberwise initializers are never public by default, so we
    868     // declare one manually.
    869     public init(issuerPubkey: String, tradeId: String, claimMutationId: String, outcome: TradeEvidenceOutcome, observedAtUnixS: String, tradeGeneration: String, statementDigest: String, supersession: RhiEvidenceSupersession?, canonicalContent: String) {
    870         self.issuerPubkey = issuerPubkey
    871         self.tradeId = tradeId
    872         self.claimMutationId = claimMutationId
    873         self.outcome = outcome
    874         self.observedAtUnixS = observedAtUnixS
    875         self.tradeGeneration = tradeGeneration
    876         self.statementDigest = statementDigest
    877         self.supersession = supersession
    878         self.canonicalContent = canonicalContent
    879     }
    880 
    881 
    882 
    883 
    884 }
    885 
    886 #if compiler(>=6)
    887 extension RhiEvidenceAttestation: Sendable {}
    888 #endif
    889 
    890 #if swift(>=5.8)
    891 @_documentation(visibility: private)
    892 #endif
    893 public struct FfiConverterTypeRhiEvidenceAttestation: FfiConverterRustBuffer {
    894     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RhiEvidenceAttestation {
    895         return
    896             try RhiEvidenceAttestation(
    897                 issuerPubkey: FfiConverterString.read(from: &buf),
    898                 tradeId: FfiConverterString.read(from: &buf),
    899                 claimMutationId: FfiConverterString.read(from: &buf),
    900                 outcome: FfiConverterTypeTradeEvidenceOutcome.read(from: &buf),
    901                 observedAtUnixS: FfiConverterString.read(from: &buf),
    902                 tradeGeneration: FfiConverterString.read(from: &buf),
    903                 statementDigest: FfiConverterString.read(from: &buf),
    904                 supersession: FfiConverterOptionTypeRhiEvidenceSupersession.read(from: &buf),
    905                 canonicalContent: FfiConverterString.read(from: &buf)
    906         )
    907     }
    908 
    909     public static func write(_ value: RhiEvidenceAttestation, into buf: inout [UInt8]) {
    910         FfiConverterString.write(value.issuerPubkey, into: &buf)
    911         FfiConverterString.write(value.tradeId, into: &buf)
    912         FfiConverterString.write(value.claimMutationId, into: &buf)
    913         FfiConverterTypeTradeEvidenceOutcome.write(value.outcome, into: &buf)
    914         FfiConverterString.write(value.observedAtUnixS, into: &buf)
    915         FfiConverterString.write(value.tradeGeneration, into: &buf)
    916         FfiConverterString.write(value.statementDigest, into: &buf)
    917         FfiConverterOptionTypeRhiEvidenceSupersession.write(value.supersession, into: &buf)
    918         FfiConverterString.write(value.canonicalContent, into: &buf)
    919     }
    920 }
    921 
    922 
    923 #if swift(>=5.8)
    924 @_documentation(visibility: private)
    925 #endif
    926 public func FfiConverterTypeRhiEvidenceAttestation_lift(_ buf: RustBuffer) throws -> RhiEvidenceAttestation {
    927     return try FfiConverterTypeRhiEvidenceAttestation.lift(buf)
    928 }
    929 
    930 #if swift(>=5.8)
    931 @_documentation(visibility: private)
    932 #endif
    933 public func FfiConverterTypeRhiEvidenceAttestation_lower(_ value: RhiEvidenceAttestation) -> RustBuffer {
    934     return FfiConverterTypeRhiEvidenceAttestation.lower(value)
    935 }
    936 
    937 
    938 /**
    939  * Bounded projection of one canonical RHI evidence report.
    940  */
    941 public struct RhiEvidenceReport: Equatable, Hashable {
    942     public var contractId: String
    943     public var contractVersion: UInt16
    944     public var issuerPubkey: String
    945     public var tradeId: String
    946     public var claimMutationId: String
    947     public var outcome: TradeEvidenceOutcome
    948     public var reasonCodes: [String]
    949     public var projectionDigest: String
    950     public var evidenceManifestDigest: String
    951     public var evidencePolicyDigest: String
    952     public var observedAtUnixS: String
    953     public var tradeGeneration: String
    954     public var statementDigest: String
    955     public var supersession: RhiEvidenceSupersession?
    956     public var canonicalContent: String
    957 
    958     // Default memberwise initializers are never public by default, so we
    959     // declare one manually.
    960     public init(contractId: String, contractVersion: UInt16, issuerPubkey: String, tradeId: String, claimMutationId: String, outcome: TradeEvidenceOutcome, reasonCodes: [String], projectionDigest: String, evidenceManifestDigest: String, evidencePolicyDigest: String, observedAtUnixS: String, tradeGeneration: String, statementDigest: String, supersession: RhiEvidenceSupersession?, canonicalContent: String) {
    961         self.contractId = contractId
    962         self.contractVersion = contractVersion
    963         self.issuerPubkey = issuerPubkey
    964         self.tradeId = tradeId
    965         self.claimMutationId = claimMutationId
    966         self.outcome = outcome
    967         self.reasonCodes = reasonCodes
    968         self.projectionDigest = projectionDigest
    969         self.evidenceManifestDigest = evidenceManifestDigest
    970         self.evidencePolicyDigest = evidencePolicyDigest
    971         self.observedAtUnixS = observedAtUnixS
    972         self.tradeGeneration = tradeGeneration
    973         self.statementDigest = statementDigest
    974         self.supersession = supersession
    975         self.canonicalContent = canonicalContent
    976     }
    977 
    978 
    979 
    980 
    981 }
    982 
    983 #if compiler(>=6)
    984 extension RhiEvidenceReport: Sendable {}
    985 #endif
    986 
    987 #if swift(>=5.8)
    988 @_documentation(visibility: private)
    989 #endif
    990 public struct FfiConverterTypeRhiEvidenceReport: FfiConverterRustBuffer {
    991     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RhiEvidenceReport {
    992         return
    993             try RhiEvidenceReport(
    994                 contractId: FfiConverterString.read(from: &buf),
    995                 contractVersion: FfiConverterUInt16.read(from: &buf),
    996                 issuerPubkey: FfiConverterString.read(from: &buf),
    997                 tradeId: FfiConverterString.read(from: &buf),
    998                 claimMutationId: FfiConverterString.read(from: &buf),
    999                 outcome: FfiConverterTypeTradeEvidenceOutcome.read(from: &buf),
   1000                 reasonCodes: FfiConverterSequenceString.read(from: &buf),
   1001                 projectionDigest: FfiConverterString.read(from: &buf),
   1002                 evidenceManifestDigest: FfiConverterString.read(from: &buf),
   1003                 evidencePolicyDigest: FfiConverterString.read(from: &buf),
   1004                 observedAtUnixS: FfiConverterString.read(from: &buf),
   1005                 tradeGeneration: FfiConverterString.read(from: &buf),
   1006                 statementDigest: FfiConverterString.read(from: &buf),
   1007                 supersession: FfiConverterOptionTypeRhiEvidenceSupersession.read(from: &buf),
   1008                 canonicalContent: FfiConverterString.read(from: &buf)
   1009         )
   1010     }
   1011 
   1012     public static func write(_ value: RhiEvidenceReport, into buf: inout [UInt8]) {
   1013         FfiConverterString.write(value.contractId, into: &buf)
   1014         FfiConverterUInt16.write(value.contractVersion, into: &buf)
   1015         FfiConverterString.write(value.issuerPubkey, into: &buf)
   1016         FfiConverterString.write(value.tradeId, into: &buf)
   1017         FfiConverterString.write(value.claimMutationId, into: &buf)
   1018         FfiConverterTypeTradeEvidenceOutcome.write(value.outcome, into: &buf)
   1019         FfiConverterSequenceString.write(value.reasonCodes, into: &buf)
   1020         FfiConverterString.write(value.projectionDigest, into: &buf)
   1021         FfiConverterString.write(value.evidenceManifestDigest, into: &buf)
   1022         FfiConverterString.write(value.evidencePolicyDigest, into: &buf)
   1023         FfiConverterString.write(value.observedAtUnixS, into: &buf)
   1024         FfiConverterString.write(value.tradeGeneration, into: &buf)
   1025         FfiConverterString.write(value.statementDigest, into: &buf)
   1026         FfiConverterOptionTypeRhiEvidenceSupersession.write(value.supersession, into: &buf)
   1027         FfiConverterString.write(value.canonicalContent, into: &buf)
   1028     }
   1029 }
   1030 
   1031 
   1032 #if swift(>=5.8)
   1033 @_documentation(visibility: private)
   1034 #endif
   1035 public func FfiConverterTypeRhiEvidenceReport_lift(_ buf: RustBuffer) throws -> RhiEvidenceReport {
   1036     return try FfiConverterTypeRhiEvidenceReport.lift(buf)
   1037 }
   1038 
   1039 #if swift(>=5.8)
   1040 @_documentation(visibility: private)
   1041 #endif
   1042 public func FfiConverterTypeRhiEvidenceReport_lower(_ value: RhiEvidenceReport) -> RustBuffer {
   1043     return FfiConverterTypeRhiEvidenceReport.lower(value)
   1044 }
   1045 
   1046 
   1047 /**
   1048  * Exact immutable RHI supersession reference.
   1049  */
   1050 public struct RhiEvidenceSupersession: Equatable, Hashable {
   1051     public var reportId: String
   1052     public var eventId: String
   1053 
   1054     // Default memberwise initializers are never public by default, so we
   1055     // declare one manually.
   1056     public init(reportId: String, eventId: String) {
   1057         self.reportId = reportId
   1058         self.eventId = eventId
   1059     }
   1060 
   1061 
   1062 
   1063 
   1064 }
   1065 
   1066 #if compiler(>=6)
   1067 extension RhiEvidenceSupersession: Sendable {}
   1068 #endif
   1069 
   1070 #if swift(>=5.8)
   1071 @_documentation(visibility: private)
   1072 #endif
   1073 public struct FfiConverterTypeRhiEvidenceSupersession: FfiConverterRustBuffer {
   1074     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RhiEvidenceSupersession {
   1075         return
   1076             try RhiEvidenceSupersession(
   1077                 reportId: FfiConverterString.read(from: &buf),
   1078                 eventId: FfiConverterString.read(from: &buf)
   1079         )
   1080     }
   1081 
   1082     public static func write(_ value: RhiEvidenceSupersession, into buf: inout [UInt8]) {
   1083         FfiConverterString.write(value.reportId, into: &buf)
   1084         FfiConverterString.write(value.eventId, into: &buf)
   1085     }
   1086 }
   1087 
   1088 
   1089 #if swift(>=5.8)
   1090 @_documentation(visibility: private)
   1091 #endif
   1092 public func FfiConverterTypeRhiEvidenceSupersession_lift(_ buf: RustBuffer) throws -> RhiEvidenceSupersession {
   1093     return try FfiConverterTypeRhiEvidenceSupersession.lift(buf)
   1094 }
   1095 
   1096 #if swift(>=5.8)
   1097 @_documentation(visibility: private)
   1098 #endif
   1099 public func FfiConverterTypeRhiEvidenceSupersession_lower(_ value: RhiEvidenceSupersession) -> RustBuffer {
   1100     return FfiConverterTypeRhiEvidenceSupersession.lower(value)
   1101 }
   1102 
   1103 
   1104 /**
   1105  * Signed NIP-01 event input for verified attestation admission.
   1106  */
   1107 public struct SignedEvent: Equatable, Hashable {
   1108     public var id: String
   1109     public var authorPubkey: String
   1110     public var createdAtUnixS: UInt64
   1111     public var kind: UInt32
   1112     public var tags: [[String]]
   1113     public var content: String
   1114     public var signature: String
   1115 
   1116     // Default memberwise initializers are never public by default, so we
   1117     // declare one manually.
   1118     public init(id: String, authorPubkey: String, createdAtUnixS: UInt64, kind: UInt32, tags: [[String]], content: String, signature: String) {
   1119         self.id = id
   1120         self.authorPubkey = authorPubkey
   1121         self.createdAtUnixS = createdAtUnixS
   1122         self.kind = kind
   1123         self.tags = tags
   1124         self.content = content
   1125         self.signature = signature
   1126     }
   1127 
   1128 
   1129 
   1130 
   1131 }
   1132 
   1133 #if compiler(>=6)
   1134 extension SignedEvent: Sendable {}
   1135 #endif
   1136 
   1137 #if swift(>=5.8)
   1138 @_documentation(visibility: private)
   1139 #endif
   1140 public struct FfiConverterTypeSignedEvent: FfiConverterRustBuffer {
   1141     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignedEvent {
   1142         return
   1143             try SignedEvent(
   1144                 id: FfiConverterString.read(from: &buf),
   1145                 authorPubkey: FfiConverterString.read(from: &buf),
   1146                 createdAtUnixS: FfiConverterUInt64.read(from: &buf),
   1147                 kind: FfiConverterUInt32.read(from: &buf),
   1148                 tags: FfiConverterSequenceSequenceString.read(from: &buf),
   1149                 content: FfiConverterString.read(from: &buf),
   1150                 signature: FfiConverterString.read(from: &buf)
   1151         )
   1152     }
   1153 
   1154     public static func write(_ value: SignedEvent, into buf: inout [UInt8]) {
   1155         FfiConverterString.write(value.id, into: &buf)
   1156         FfiConverterString.write(value.authorPubkey, into: &buf)
   1157         FfiConverterUInt64.write(value.createdAtUnixS, into: &buf)
   1158         FfiConverterUInt32.write(value.kind, into: &buf)
   1159         FfiConverterSequenceSequenceString.write(value.tags, into: &buf)
   1160         FfiConverterString.write(value.content, into: &buf)
   1161         FfiConverterString.write(value.signature, into: &buf)
   1162     }
   1163 }
   1164 
   1165 
   1166 #if swift(>=5.8)
   1167 @_documentation(visibility: private)
   1168 #endif
   1169 public func FfiConverterTypeSignedEvent_lift(_ buf: RustBuffer) throws -> SignedEvent {
   1170     return try FfiConverterTypeSignedEvent.lift(buf)
   1171 }
   1172 
   1173 #if swift(>=5.8)
   1174 @_documentation(visibility: private)
   1175 #endif
   1176 public func FfiConverterTypeSignedEvent_lower(_ value: SignedEvent) -> RustBuffer {
   1177     return FfiConverterTypeSignedEvent.lower(value)
   1178 }
   1179 
   1180 
   1181 /**
   1182  * Bounded projection of one canonical evidence manifest.
   1183  */
   1184 public struct TradeEvidenceManifest: Equatable, Hashable {
   1185     public var contractId: String
   1186     public var contractVersion: UInt16
   1187     public var tradeId: String
   1188     public var tradeGeneration: String
   1189     public var observedAtUnixS: String
   1190     public var coverage: TradeEvidenceCoverage
   1191     public var evidencePolicyDigest: String
   1192     public var manifestDigest: String
   1193     public var canonicalBytesHex: String
   1194 
   1195     // Default memberwise initializers are never public by default, so we
   1196     // declare one manually.
   1197     public init(contractId: String, contractVersion: UInt16, tradeId: String, tradeGeneration: String, observedAtUnixS: String, coverage: TradeEvidenceCoverage, evidencePolicyDigest: String, manifestDigest: String, canonicalBytesHex: String) {
   1198         self.contractId = contractId
   1199         self.contractVersion = contractVersion
   1200         self.tradeId = tradeId
   1201         self.tradeGeneration = tradeGeneration
   1202         self.observedAtUnixS = observedAtUnixS
   1203         self.coverage = coverage
   1204         self.evidencePolicyDigest = evidencePolicyDigest
   1205         self.manifestDigest = manifestDigest
   1206         self.canonicalBytesHex = canonicalBytesHex
   1207     }
   1208 
   1209 
   1210 
   1211 
   1212 }
   1213 
   1214 #if compiler(>=6)
   1215 extension TradeEvidenceManifest: Sendable {}
   1216 #endif
   1217 
   1218 #if swift(>=5.8)
   1219 @_documentation(visibility: private)
   1220 #endif
   1221 public struct FfiConverterTypeTradeEvidenceManifest: FfiConverterRustBuffer {
   1222     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TradeEvidenceManifest {
   1223         return
   1224             try TradeEvidenceManifest(
   1225                 contractId: FfiConverterString.read(from: &buf),
   1226                 contractVersion: FfiConverterUInt16.read(from: &buf),
   1227                 tradeId: FfiConverterString.read(from: &buf),
   1228                 tradeGeneration: FfiConverterString.read(from: &buf),
   1229                 observedAtUnixS: FfiConverterString.read(from: &buf),
   1230                 coverage: FfiConverterTypeTradeEvidenceCoverage.read(from: &buf),
   1231                 evidencePolicyDigest: FfiConverterString.read(from: &buf),
   1232                 manifestDigest: FfiConverterString.read(from: &buf),
   1233                 canonicalBytesHex: FfiConverterString.read(from: &buf)
   1234         )
   1235     }
   1236 
   1237     public static func write(_ value: TradeEvidenceManifest, into buf: inout [UInt8]) {
   1238         FfiConverterString.write(value.contractId, into: &buf)
   1239         FfiConverterUInt16.write(value.contractVersion, into: &buf)
   1240         FfiConverterString.write(value.tradeId, into: &buf)
   1241         FfiConverterString.write(value.tradeGeneration, into: &buf)
   1242         FfiConverterString.write(value.observedAtUnixS, into: &buf)
   1243         FfiConverterTypeTradeEvidenceCoverage.write(value.coverage, into: &buf)
   1244         FfiConverterString.write(value.evidencePolicyDigest, into: &buf)
   1245         FfiConverterString.write(value.manifestDigest, into: &buf)
   1246         FfiConverterString.write(value.canonicalBytesHex, into: &buf)
   1247     }
   1248 }
   1249 
   1250 
   1251 #if swift(>=5.8)
   1252 @_documentation(visibility: private)
   1253 #endif
   1254 public func FfiConverterTypeTradeEvidenceManifest_lift(_ buf: RustBuffer) throws -> TradeEvidenceManifest {
   1255     return try FfiConverterTypeTradeEvidenceManifest.lift(buf)
   1256 }
   1257 
   1258 #if swift(>=5.8)
   1259 @_documentation(visibility: private)
   1260 #endif
   1261 public func FfiConverterTypeTradeEvidenceManifest_lower(_ value: TradeEvidenceManifest) -> RustBuffer {
   1262     return FfiConverterTypeTradeEvidenceManifest.lower(value)
   1263 }
   1264 
   1265 
   1266 /**
   1267  * One unsigned typed event plan ready for host-owned signing.
   1268  */
   1269 public struct TypedEvidenceEventPlan: Equatable, Hashable {
   1270     public var contractId: String
   1271     public var kind: UInt32
   1272     public var authorPubkey: String
   1273     public var createdAtUnixS: String
   1274     public var expectedEventId: String
   1275     public var tags: [[String]]
   1276     public var content: String
   1277 
   1278     // Default memberwise initializers are never public by default, so we
   1279     // declare one manually.
   1280     public init(contractId: String, kind: UInt32, authorPubkey: String, createdAtUnixS: String, expectedEventId: String, tags: [[String]], content: String) {
   1281         self.contractId = contractId
   1282         self.kind = kind
   1283         self.authorPubkey = authorPubkey
   1284         self.createdAtUnixS = createdAtUnixS
   1285         self.expectedEventId = expectedEventId
   1286         self.tags = tags
   1287         self.content = content
   1288     }
   1289 
   1290 
   1291 
   1292 
   1293 }
   1294 
   1295 #if compiler(>=6)
   1296 extension TypedEvidenceEventPlan: Sendable {}
   1297 #endif
   1298 
   1299 #if swift(>=5.8)
   1300 @_documentation(visibility: private)
   1301 #endif
   1302 public struct FfiConverterTypeTypedEvidenceEventPlan: FfiConverterRustBuffer {
   1303     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TypedEvidenceEventPlan {
   1304         return
   1305             try TypedEvidenceEventPlan(
   1306                 contractId: FfiConverterString.read(from: &buf),
   1307                 kind: FfiConverterUInt32.read(from: &buf),
   1308                 authorPubkey: FfiConverterString.read(from: &buf),
   1309                 createdAtUnixS: FfiConverterString.read(from: &buf),
   1310                 expectedEventId: FfiConverterString.read(from: &buf),
   1311                 tags: FfiConverterSequenceSequenceString.read(from: &buf),
   1312                 content: FfiConverterString.read(from: &buf)
   1313         )
   1314     }
   1315 
   1316     public static func write(_ value: TypedEvidenceEventPlan, into buf: inout [UInt8]) {
   1317         FfiConverterString.write(value.contractId, into: &buf)
   1318         FfiConverterUInt32.write(value.kind, into: &buf)
   1319         FfiConverterString.write(value.authorPubkey, into: &buf)
   1320         FfiConverterString.write(value.createdAtUnixS, into: &buf)
   1321         FfiConverterString.write(value.expectedEventId, into: &buf)
   1322         FfiConverterSequenceSequenceString.write(value.tags, into: &buf)
   1323         FfiConverterString.write(value.content, into: &buf)
   1324     }
   1325 }
   1326 
   1327 
   1328 #if swift(>=5.8)
   1329 @_documentation(visibility: private)
   1330 #endif
   1331 public func FfiConverterTypeTypedEvidenceEventPlan_lift(_ buf: RustBuffer) throws -> TypedEvidenceEventPlan {
   1332     return try FfiConverterTypeTypedEvidenceEventPlan.lift(buf)
   1333 }
   1334 
   1335 #if swift(>=5.8)
   1336 @_documentation(visibility: private)
   1337 #endif
   1338 public func FfiConverterTypeTypedEvidenceEventPlan_lower(_ value: TypedEvidenceEventPlan) -> RustBuffer {
   1339     return FfiConverterTypeTypedEvidenceEventPlan.lower(value)
   1340 }
   1341 
   1342 
   1343 /**
   1344  * Current side-effect-free capability availability.
   1345  */
   1346 
   1347 public enum CapabilityAvailability: Equatable, Hashable {
   1348 
   1349     case available
   1350     case degraded
   1351     case unavailable
   1352     case unsupported
   1353 
   1354 
   1355 
   1356 
   1357 
   1358 }
   1359 
   1360 #if compiler(>=6)
   1361 extension CapabilityAvailability: Sendable {}
   1362 #endif
   1363 
   1364 #if swift(>=5.8)
   1365 @_documentation(visibility: private)
   1366 #endif
   1367 public struct FfiConverterTypeCapabilityAvailability: FfiConverterRustBuffer {
   1368     typealias SwiftType = CapabilityAvailability
   1369 
   1370     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CapabilityAvailability {
   1371         let variant: Int32 = try readInt(&buf)
   1372         switch variant {
   1373 
   1374         case 1: return .available
   1375 
   1376         case 2: return .degraded
   1377 
   1378         case 3: return .unavailable
   1379 
   1380         case 4: return .unsupported
   1381 
   1382         default: throw UniffiInternalError.unexpectedEnumCase
   1383         }
   1384     }
   1385 
   1386     public static func write(_ value: CapabilityAvailability, into buf: inout [UInt8]) {
   1387         switch value {
   1388 
   1389 
   1390         case .available:
   1391             writeInt(&buf, Int32(1))
   1392 
   1393 
   1394         case .degraded:
   1395             writeInt(&buf, Int32(2))
   1396 
   1397 
   1398         case .unavailable:
   1399             writeInt(&buf, Int32(3))
   1400 
   1401 
   1402         case .unsupported:
   1403             writeInt(&buf, Int32(4))
   1404 
   1405         }
   1406     }
   1407 }
   1408 
   1409 
   1410 #if swift(>=5.8)
   1411 @_documentation(visibility: private)
   1412 #endif
   1413 public func FfiConverterTypeCapabilityAvailability_lift(_ buf: RustBuffer) throws -> CapabilityAvailability {
   1414     return try FfiConverterTypeCapabilityAvailability.lift(buf)
   1415 }
   1416 
   1417 #if swift(>=5.8)
   1418 @_documentation(visibility: private)
   1419 #endif
   1420 public func FfiConverterTypeCapabilityAvailability_lower(_ value: CapabilityAvailability) -> RustBuffer {
   1421     return FfiConverterTypeCapabilityAvailability.lower(value)
   1422 }
   1423 
   1424 
   1425 
   1426 /**
   1427  * Stable capability maturity independent of runtime availability.
   1428  */
   1429 
   1430 public enum CapabilityMaturity: Equatable, Hashable {
   1431 
   1432     case stable
   1433     case preview
   1434     case experimental
   1435 
   1436 
   1437 
   1438 
   1439 
   1440 }
   1441 
   1442 #if compiler(>=6)
   1443 extension CapabilityMaturity: Sendable {}
   1444 #endif
   1445 
   1446 #if swift(>=5.8)
   1447 @_documentation(visibility: private)
   1448 #endif
   1449 public struct FfiConverterTypeCapabilityMaturity: FfiConverterRustBuffer {
   1450     typealias SwiftType = CapabilityMaturity
   1451 
   1452     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CapabilityMaturity {
   1453         let variant: Int32 = try readInt(&buf)
   1454         switch variant {
   1455 
   1456         case 1: return .stable
   1457 
   1458         case 2: return .preview
   1459 
   1460         case 3: return .experimental
   1461 
   1462         default: throw UniffiInternalError.unexpectedEnumCase
   1463         }
   1464     }
   1465 
   1466     public static func write(_ value: CapabilityMaturity, into buf: inout [UInt8]) {
   1467         switch value {
   1468 
   1469 
   1470         case .stable:
   1471             writeInt(&buf, Int32(1))
   1472 
   1473 
   1474         case .preview:
   1475             writeInt(&buf, Int32(2))
   1476 
   1477 
   1478         case .experimental:
   1479             writeInt(&buf, Int32(3))
   1480 
   1481         }
   1482     }
   1483 }
   1484 
   1485 
   1486 #if swift(>=5.8)
   1487 @_documentation(visibility: private)
   1488 #endif
   1489 public func FfiConverterTypeCapabilityMaturity_lift(_ buf: RustBuffer) throws -> CapabilityMaturity {
   1490     return try FfiConverterTypeCapabilityMaturity.lift(buf)
   1491 }
   1492 
   1493 #if swift(>=5.8)
   1494 @_documentation(visibility: private)
   1495 #endif
   1496 public func FfiConverterTypeCapabilityMaturity_lower(_ value: CapabilityMaturity) -> RustBuffer {
   1497     return FfiConverterTypeCapabilityMaturity.lower(value)
   1498 }
   1499 
   1500 
   1501 
   1502 /**
   1503  * Secret-safe SDK failure at the language boundary.
   1504  */
   1505 public
   1506 enum Error: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
   1507 
   1508 
   1509 
   1510     case Sdk(code: String, message: String, retryable: Bool
   1511     )
   1512 
   1513 
   1514 
   1515 
   1516 
   1517 
   1518     public var errorDescription: String? {
   1519         String(reflecting: self)
   1520     }
   1521 
   1522 }
   1523 
   1524 #if compiler(>=6)
   1525 extension Error: Sendable {}
   1526 #endif
   1527 
   1528 #if swift(>=5.8)
   1529 @_documentation(visibility: private)
   1530 #endif
   1531 public struct FfiConverterTypeError: FfiConverterRustBuffer {
   1532     typealias SwiftType = Error
   1533 
   1534     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Error {
   1535         let variant: Int32 = try readInt(&buf)
   1536         switch variant {
   1537 
   1538 
   1539 
   1540 
   1541         case 1: return .Sdk(
   1542             code: try FfiConverterString.read(from: &buf),
   1543             message: try FfiConverterString.read(from: &buf),
   1544             retryable: try FfiConverterBool.read(from: &buf)
   1545             )
   1546 
   1547          default: throw UniffiInternalError.unexpectedEnumCase
   1548         }
   1549     }
   1550 
   1551     public static func write(_ value: Error, into buf: inout [UInt8]) {
   1552         switch value {
   1553 
   1554 
   1555 
   1556 
   1557 
   1558         case let .Sdk(code,message,retryable):
   1559             writeInt(&buf, Int32(1))
   1560             FfiConverterString.write(code, into: &buf)
   1561             FfiConverterString.write(message, into: &buf)
   1562             FfiConverterBool.write(retryable, into: &buf)
   1563 
   1564         }
   1565     }
   1566 }
   1567 
   1568 
   1569 #if swift(>=5.8)
   1570 @_documentation(visibility: private)
   1571 #endif
   1572 public func FfiConverterTypeError_lift(_ buf: RustBuffer) throws -> Error {
   1573     return try FfiConverterTypeError.lift(buf)
   1574 }
   1575 
   1576 #if swift(>=5.8)
   1577 @_documentation(visibility: private)
   1578 #endif
   1579 public func FfiConverterTypeError_lower(_ value: Error) -> RustBuffer {
   1580     return FfiConverterTypeError.lower(value)
   1581 }
   1582 
   1583 
   1584 /**
   1585  * Final evidence coverage vocabulary.
   1586  */
   1587 
   1588 public enum TradeEvidenceCoverage: Equatable, Hashable {
   1589 
   1590     case missing
   1591     case partial
   1592     case scopeSatisfied
   1593     case unsupported
   1594 
   1595 
   1596 
   1597 
   1598 
   1599 }
   1600 
   1601 #if compiler(>=6)
   1602 extension TradeEvidenceCoverage: Sendable {}
   1603 #endif
   1604 
   1605 #if swift(>=5.8)
   1606 @_documentation(visibility: private)
   1607 #endif
   1608 public struct FfiConverterTypeTradeEvidenceCoverage: FfiConverterRustBuffer {
   1609     typealias SwiftType = TradeEvidenceCoverage
   1610 
   1611     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TradeEvidenceCoverage {
   1612         let variant: Int32 = try readInt(&buf)
   1613         switch variant {
   1614 
   1615         case 1: return .missing
   1616 
   1617         case 2: return .partial
   1618 
   1619         case 3: return .scopeSatisfied
   1620 
   1621         case 4: return .unsupported
   1622 
   1623         default: throw UniffiInternalError.unexpectedEnumCase
   1624         }
   1625     }
   1626 
   1627     public static func write(_ value: TradeEvidenceCoverage, into buf: inout [UInt8]) {
   1628         switch value {
   1629 
   1630 
   1631         case .missing:
   1632             writeInt(&buf, Int32(1))
   1633 
   1634 
   1635         case .partial:
   1636             writeInt(&buf, Int32(2))
   1637 
   1638 
   1639         case .scopeSatisfied:
   1640             writeInt(&buf, Int32(3))
   1641 
   1642 
   1643         case .unsupported:
   1644             writeInt(&buf, Int32(4))
   1645 
   1646         }
   1647     }
   1648 }
   1649 
   1650 
   1651 #if swift(>=5.8)
   1652 @_documentation(visibility: private)
   1653 #endif
   1654 public func FfiConverterTypeTradeEvidenceCoverage_lift(_ buf: RustBuffer) throws -> TradeEvidenceCoverage {
   1655     return try FfiConverterTypeTradeEvidenceCoverage.lift(buf)
   1656 }
   1657 
   1658 #if swift(>=5.8)
   1659 @_documentation(visibility: private)
   1660 #endif
   1661 public func FfiConverterTypeTradeEvidenceCoverage_lower(_ value: TradeEvidenceCoverage) -> RustBuffer {
   1662     return FfiConverterTypeTradeEvidenceCoverage.lower(value)
   1663 }
   1664 
   1665 
   1666 
   1667 /**
   1668  * Final evidence outcome vocabulary.
   1669  */
   1670 
   1671 public enum TradeEvidenceOutcome: Equatable, Hashable {
   1672 
   1673     case valid
   1674     case invalid
   1675     case indeterminate
   1676 
   1677 
   1678 
   1679 
   1680 
   1681 }
   1682 
   1683 #if compiler(>=6)
   1684 extension TradeEvidenceOutcome: Sendable {}
   1685 #endif
   1686 
   1687 #if swift(>=5.8)
   1688 @_documentation(visibility: private)
   1689 #endif
   1690 public struct FfiConverterTypeTradeEvidenceOutcome: FfiConverterRustBuffer {
   1691     typealias SwiftType = TradeEvidenceOutcome
   1692 
   1693     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TradeEvidenceOutcome {
   1694         let variant: Int32 = try readInt(&buf)
   1695         switch variant {
   1696 
   1697         case 1: return .valid
   1698 
   1699         case 2: return .invalid
   1700 
   1701         case 3: return .indeterminate
   1702 
   1703         default: throw UniffiInternalError.unexpectedEnumCase
   1704         }
   1705     }
   1706 
   1707     public static func write(_ value: TradeEvidenceOutcome, into buf: inout [UInt8]) {
   1708         switch value {
   1709 
   1710 
   1711         case .valid:
   1712             writeInt(&buf, Int32(1))
   1713 
   1714 
   1715         case .invalid:
   1716             writeInt(&buf, Int32(2))
   1717 
   1718 
   1719         case .indeterminate:
   1720             writeInt(&buf, Int32(3))
   1721 
   1722         }
   1723     }
   1724 }
   1725 
   1726 
   1727 #if swift(>=5.8)
   1728 @_documentation(visibility: private)
   1729 #endif
   1730 public func FfiConverterTypeTradeEvidenceOutcome_lift(_ buf: RustBuffer) throws -> TradeEvidenceOutcome {
   1731     return try FfiConverterTypeTradeEvidenceOutcome.lift(buf)
   1732 }
   1733 
   1734 #if swift(>=5.8)
   1735 @_documentation(visibility: private)
   1736 #endif
   1737 public func FfiConverterTypeTradeEvidenceOutcome_lower(_ value: TradeEvidenceOutcome) -> RustBuffer {
   1738     return FfiConverterTypeTradeEvidenceOutcome.lower(value)
   1739 }
   1740 
   1741 
   1742 #if swift(>=5.8)
   1743 @_documentation(visibility: private)
   1744 #endif
   1745 fileprivate struct FfiConverterOptionTypeRhiEvidenceSupersession: FfiConverterRustBuffer {
   1746     typealias SwiftType = RhiEvidenceSupersession?
   1747 
   1748     public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
   1749         guard let value = value else {
   1750             writeInt(&buf, Int8(0))
   1751             return
   1752         }
   1753         writeInt(&buf, Int8(1))
   1754         FfiConverterTypeRhiEvidenceSupersession.write(value, into: &buf)
   1755     }
   1756 
   1757     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
   1758         switch try readInt(&buf) as Int8 {
   1759         case 0: return nil
   1760         case 1: return try FfiConverterTypeRhiEvidenceSupersession.read(from: &buf)
   1761         default: throw UniffiInternalError.unexpectedOptionalTag
   1762         }
   1763     }
   1764 }
   1765 
   1766 #if swift(>=5.8)
   1767 @_documentation(visibility: private)
   1768 #endif
   1769 fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
   1770     typealias SwiftType = [String]
   1771 
   1772     public static func write(_ value: [String], into buf: inout [UInt8]) {
   1773         let len = Int32(value.count)
   1774         writeInt(&buf, len)
   1775         for item in value {
   1776             FfiConverterString.write(item, into: &buf)
   1777         }
   1778     }
   1779 
   1780     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
   1781         let len: Int32 = try readInt(&buf)
   1782         var seq = [String]()
   1783         seq.reserveCapacity(Int(len))
   1784         for _ in 0 ..< len {
   1785             seq.append(try FfiConverterString.read(from: &buf))
   1786         }
   1787         return seq
   1788     }
   1789 }
   1790 
   1791 #if swift(>=5.8)
   1792 @_documentation(visibility: private)
   1793 #endif
   1794 fileprivate struct FfiConverterSequenceTypeCapabilityStatus: FfiConverterRustBuffer {
   1795     typealias SwiftType = [CapabilityStatus]
   1796 
   1797     public static func write(_ value: [CapabilityStatus], into buf: inout [UInt8]) {
   1798         let len = Int32(value.count)
   1799         writeInt(&buf, len)
   1800         for item in value {
   1801             FfiConverterTypeCapabilityStatus.write(item, into: &buf)
   1802         }
   1803     }
   1804 
   1805     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CapabilityStatus] {
   1806         let len: Int32 = try readInt(&buf)
   1807         var seq = [CapabilityStatus]()
   1808         seq.reserveCapacity(Int(len))
   1809         for _ in 0 ..< len {
   1810             seq.append(try FfiConverterTypeCapabilityStatus.read(from: &buf))
   1811         }
   1812         return seq
   1813     }
   1814 }
   1815 
   1816 #if swift(>=5.8)
   1817 @_documentation(visibility: private)
   1818 #endif
   1819 fileprivate struct FfiConverterSequenceSequenceString: FfiConverterRustBuffer {
   1820     typealias SwiftType = [[String]]
   1821 
   1822     public static func write(_ value: [[String]], into buf: inout [UInt8]) {
   1823         let len = Int32(value.count)
   1824         writeInt(&buf, len)
   1825         for item in value {
   1826             FfiConverterSequenceString.write(item, into: &buf)
   1827         }
   1828     }
   1829 
   1830     public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [[String]] {
   1831         let len: Int32 = try readInt(&buf)
   1832         var seq = [[String]]()
   1833         seq.reserveCapacity(Int(len))
   1834         for _ in 0 ..< len {
   1835             seq.append(try FfiConverterSequenceString.read(from: &buf))
   1836         }
   1837         return seq
   1838     }
   1839 }
   1840 private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
   1841 private let UNIFFI_RUST_FUTURE_POLL_WAKE: Int8 = 1
   1842 
   1843 fileprivate let uniffiContinuationHandleMap = UniffiHandleMap<UnsafeContinuation<Int8, Never>>()
   1844 
   1845 // radroots-swift-cancellation-v1. Only the observing Rust future is cancelled;
   1846 // admitted work and obtained material remain owned by the shared runtime.
   1847 // NSLock serializes cancel against release. The unchecked Sendable owner has
   1848 // no unsynchronized mutable state; its immutable C callback is Sendable.
   1849 fileprivate final class UniffiRustCancellation: @unchecked Sendable {
   1850     private let lock = NSLock()
   1851     private var handle: UInt64?
   1852     private let cancelFunction: @Sendable (UInt64) -> Void
   1853     init(_ handle: UInt64, _ cancelFunction: @escaping @Sendable (UInt64) -> Void) {
   1854         self.handle = handle
   1855         self.cancelFunction = cancelFunction
   1856     }
   1857     func cancel() {
   1858         lock.lock()
   1859         defer { lock.unlock() }
   1860         if let handle { cancelFunction(handle) }
   1861     }
   1862     func finish() {
   1863         lock.lock()
   1864         defer { lock.unlock() }
   1865         handle = nil
   1866     }
   1867 }
   1868 
   1869 fileprivate func uniffiRustCallAsync<F, T>(
   1870     rustFutureFunc: () -> UInt64,
   1871     pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (),
   1872     completeFunc: (UInt64, UnsafeMutablePointer<RustCallStatus>) -> F,
   1873     cancelFunc: @escaping @Sendable (UInt64) -> Void,
   1874     freeFunc: (UInt64) -> (),
   1875     liftFunc: (F) throws -> T,
   1876     errorHandler: ((RustBuffer) throws -> Swift.Error)?
   1877 ) async throws -> T {
   1878     try Task.checkCancellation()
   1879     uniffiEnsureRadrootsSdkFfiInitialized()
   1880     let handle = rustFutureFunc()
   1881     let cancellation = UniffiRustCancellation(handle, cancelFunc)
   1882     defer {
   1883         cancellation.finish()
   1884         freeFunc(handle)
   1885     }
   1886     return try await withTaskCancellationHandler {
   1887         var ready: Int8
   1888         repeat {
   1889             ready = await withUnsafeContinuation { continuation in
   1890                 let callbackHandle = uniffiContinuationHandleMap.insert(obj: continuation)
   1891                 pollFunc(handle, { callbackHandle, status in
   1892                     uniffiFutureContinuationCallback(handle: callbackHandle, pollResult: status)
   1893                 }, callbackHandle)
   1894             }
   1895         } while ready != UNIFFI_RUST_FUTURE_POLL_READY
   1896         let result = try makeRustCall({ completeFunc(handle, $0) }, errorHandler: errorHandler)
   1897         return try liftFunc(result)
   1898     } onCancel: {
   1899         cancellation.cancel()
   1900     }
   1901 }
   1902 
   1903 // Callback handlers for an async calls.  These are invoked by Rust when the future is ready.  They
   1904 // lift the return value or error and resume the suspended function.
   1905 fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) {
   1906     if let continuation = try? uniffiContinuationHandleMap.remove(handle: handle) {
   1907         continuation.resume(returning: pollResult)
   1908     } else {
   1909         print("uniffiFutureContinuationCallback invalid handle")
   1910     }
   1911 }
   1912 public func parseRhiEvidenceReport(canonicalContent: String)throws  -> RhiEvidenceReport  {
   1913     return try  FfiConverterTypeRhiEvidenceReport_lift(try rustCallWithError(FfiConverterTypeError_lift) {
   1914         uniffiCallStatus in
   1915     uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report(
   1916         FfiConverterString.lower(canonicalContent),uniffiCallStatus
   1917     )
   1918 })
   1919 }
   1920 public func parseTradeEvidenceManifest(canonicalBytes: Data)throws  -> TradeEvidenceManifest  {
   1921     return try  FfiConverterTypeTradeEvidenceManifest_lift(try rustCallWithError(FfiConverterTypeError_lift) {
   1922         uniffiCallStatus in
   1923     uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest(
   1924         FfiConverterData.lower(canonicalBytes),uniffiCallStatus
   1925     )
   1926 })
   1927 }
   1928 public func prepareRhiEvidenceAttestation(canonicalContent: String, createdAtUnixS: UInt64)throws  -> TypedEvidenceEventPlan  {
   1929     return try  FfiConverterTypeTypedEvidenceEventPlan_lift(try rustCallWithError(FfiConverterTypeError_lift) {
   1930         uniffiCallStatus in
   1931     uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation(
   1932         FfiConverterString.lower(canonicalContent),
   1933         FfiConverterUInt64.lower(createdAtUnixS),uniffiCallStatus
   1934     )
   1935 })
   1936 }
   1937 public func validateRhiEvidenceAttestation(event: SignedEvent)throws  -> RhiEvidenceAttestation  {
   1938     return try  FfiConverterTypeRhiEvidenceAttestation_lift(try rustCallWithError(FfiConverterTypeError_lift) {
   1939         uniffiCallStatus in
   1940     uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation(
   1941         FfiConverterTypeSignedEvent_lower(event),uniffiCallStatus
   1942     )
   1943 })
   1944 }
   1945 
   1946 private enum InitializationResult {
   1947     case ok
   1948     case contractVersionMismatch
   1949     case apiChecksumMismatch
   1950 }
   1951 // Use a global variable to perform the versioning checks. Swift ensures that
   1952 // the code inside is only computed once.
   1953 private let initializationResult: InitializationResult = {
   1954     // Get the bindings contract version from our ComponentInterface
   1955     let bindings_contract_version = 30
   1956     // Get the scaffolding contract version by calling the into the dylib
   1957     let scaffolding_contract_version = ffi_radroots_sdk_ffi_uniffi_contract_version()
   1958     if bindings_contract_version != scaffolding_contract_version {
   1959         return InitializationResult.contractVersionMismatch
   1960     }
   1961     if (uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report() != 10431) {
   1962         return InitializationResult.apiChecksumMismatch
   1963     }
   1964     if (uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest() != 17039) {
   1965         return InitializationResult.apiChecksumMismatch
   1966     }
   1967     if (uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation() != 35556) {
   1968         return InitializationResult.apiChecksumMismatch
   1969     }
   1970     if (uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation() != 64772) {
   1971         return InitializationResult.apiChecksumMismatch
   1972     }
   1973     if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities() != 35060) {
   1974         return InitializationResult.apiChecksumMismatch
   1975     }
   1976     if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close() != 34026) {
   1977         return InitializationResult.apiChecksumMismatch
   1978     }
   1979     if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed() != 56426) {
   1980         return InitializationResult.apiChecksumMismatch
   1981     }
   1982     if (uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory() != 5837) {
   1983         return InitializationResult.apiChecksumMismatch
   1984     }
   1985 
   1986     return InitializationResult.ok
   1987 }()
   1988 
   1989 // Make the ensure init function public so that other modules which have external type references to
   1990 // our types can call it.
   1991 public func uniffiEnsureRadrootsSdkFfiInitialized() {
   1992     switch initializationResult {
   1993     case .ok:
   1994         break
   1995     case .contractVersionMismatch:
   1996         fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
   1997     case .apiChecksumMismatch:
   1998         fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
   1999     }
   2000 }
   2001 
   2002 // swiftlint:enable all