sdk

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

commit 78911e0f80d25eb61b156e5ab4fdd408a49c9619
parent 1ead928828992827b390371724b9639ea241ea12
Author: triesap <tyson@radroots.org>
Date:   Wed, 21 Oct 2026 06:03:45 +0000

bindings: adopt verified shared client provider and native generation

- Pin published Lib source and its exact catalog, archive and dependency lock.
- Regenerate four artifact routes with source-owned native lifecycle policy.
- Preserve native error fields and qualify strict Swift and Kotlin calls.
- Verify standalone packages, freshness, source policies and owning Rust checks.

Diffstat:
MCargo.lock | 40+++++++++++++++++++++++++++++-----------
MCargo.toml | 2+-
Mcontracts/generated_package_licenses.v1.json | 2+-
Mcontracts/provenance/sdk/kotlin.json | 10+++++-----
Mcontracts/provenance/sdk/swift.json | 10+++++-----
Mcontracts/provenance/sdk/typescript.json | 10+++++-----
Mcontracts/provenance/sdk/wasm.json | 10+++++-----
Mgenerated/kotlin/source.lock | 8++++----
Mgenerated/kotlin/uniffi/radroots_sdk/radroots_sdk.kt | 1101+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mgenerated/swift/radroots_sdk.swift | 681+++++++++++++++++++++++++++++--------------------------------------------------
Mgenerated/swift/radroots_sdkFFI.h | 188++++++++++++++++++++++++++++++++++---------------------------------------------
Mgenerated/swift/source.lock | 10+++++-----
Mradroots.lib.source-lock.v1.toml | 8++++----
Mtools/radroots_sdk_package_license.test.mjs | 2+-
14 files changed, 958 insertions(+), 1124 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -389,7 +389,7 @@ dependencies = [ [[package]] name = "radroots_blossom" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "mediatype", "serde", @@ -401,16 +401,26 @@ dependencies = [ [[package]] name = "radroots_core" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "rust_decimal", "serde", ] [[package]] +name = "radroots_domain" +version = "0.1.0-alpha" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" +dependencies = [ + "radroots_identity", + "serde", + "zeroize", +] + +[[package]] name = "radroots_event" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "hex", "jiff-tzdb", @@ -428,7 +438,7 @@ dependencies = [ [[package]] name = "radroots_event_codec" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "hex", "radroots_blossom", @@ -445,7 +455,7 @@ dependencies = [ [[package]] name = "radroots_identity" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "k256", "serde", @@ -455,15 +465,19 @@ dependencies = [ [[package]] name = "radroots_protocol" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ + "radroots_domain", + "radroots_identity", "serde", + "sha2", + "zeroize", ] [[package]] name = "radroots_sdk" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "radroots_core", "radroots_event", @@ -486,33 +500,37 @@ dependencies = [ [[package]] name = "radroots_signing" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "hex", + "radroots_domain", "radroots_event", "radroots_event_codec", "radroots_identity", "radroots_protocol", "sha2", + "zeroize", ] [[package]] name = "radroots_storage" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ + "radroots_domain", "radroots_event", "radroots_event_codec", "radroots_protocol", "radroots_trade", "radroots_transport", "sha2", + "zeroize", ] [[package]] name = "radroots_trade" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "hex", "radroots_core", @@ -526,7 +544,7 @@ dependencies = [ [[package]] name = "radroots_transport" version = "0.1.0-alpha" -source = "git+https://github.com/radrootslabs/lib?rev=b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4#b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +source = "git+https://github.com/radrootslabs/lib?rev=3d9f666bf9e9f66d1ade4293c516f03c88caf35a#3d9f666bf9e9f66d1ade4293c516f03c88caf35a" dependencies = [ "radroots_event", "radroots_identity", diff --git a/Cargo.toml b/Cargo.toml @@ -23,4 +23,4 @@ todo = "deny" unimplemented = "deny" [workspace.dependencies] -radroots_sdk = { package = "radroots_sdk", git = "https://github.com/radrootslabs/lib", rev = "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", version = "=0.1.0-alpha", default-features = false } +radroots_sdk = { package = "radroots_sdk", git = "https://github.com/radrootslabs/lib", rev = "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", version = "=0.1.0-alpha", default-features = false } diff --git a/contracts/generated_package_licenses.v1.json b/contracts/generated_package_licenses.v1.json @@ -1,7 +1,7 @@ { "schema": "radroots.sdk.generated-package-licenses.v1", "source_repository": "https://github.com/radrootslabs/lib", - "source_revision": "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", + "source_revision": "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", "files": [ { "name": "LICENSE-APACHE", diff --git a/contracts/provenance/sdk/kotlin.json b/contracts/provenance/sdk/kotlin.json @@ -10,12 +10,12 @@ "files": [], "provenance": { "repository": "https://github.com/radrootslabs/lib", - "revision": "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", + "revision": "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", "architecture": "radroots.crates.release.v2", - "catalog_sha256": "1e679431ad70a024affc52e6c71151459aca41707429dd8015d014d27e5f40b6", - "lockfile_sha256": "c46a2552ecc6632625064333edb96aff26fe8b3560fa7e293c1aa25fda326db1", - "source_archive_sha256": "3b27bbb1cacd5329b9c7f2f7f7bf8c826e6f06625ad8f6520f6e5e8e4278b54a", - "source_date_epoch": 1792224313, + "catalog_sha256": "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8", + "lockfile_sha256": "273129eb54f7c1f2da2ecbcdb874c862bf6966f98bd21de30b9bc0a8cd3375fd", + "source_archive_sha256": "b38794a617927c6f891af234dc8ef6f43ac25b47df39f48f0588ddfa674c643a", + "source_date_epoch": 1792562188, "builder_id": "radroots_sdk_artifact_v1", "features": [] } diff --git a/contracts/provenance/sdk/swift.json b/contracts/provenance/sdk/swift.json @@ -10,12 +10,12 @@ "files": [], "provenance": { "repository": "https://github.com/radrootslabs/lib", - "revision": "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", + "revision": "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", "architecture": "radroots.crates.release.v2", - "catalog_sha256": "1e679431ad70a024affc52e6c71151459aca41707429dd8015d014d27e5f40b6", - "lockfile_sha256": "c46a2552ecc6632625064333edb96aff26fe8b3560fa7e293c1aa25fda326db1", - "source_archive_sha256": "3b27bbb1cacd5329b9c7f2f7f7bf8c826e6f06625ad8f6520f6e5e8e4278b54a", - "source_date_epoch": 1792224313, + "catalog_sha256": "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8", + "lockfile_sha256": "273129eb54f7c1f2da2ecbcdb874c862bf6966f98bd21de30b9bc0a8cd3375fd", + "source_archive_sha256": "b38794a617927c6f891af234dc8ef6f43ac25b47df39f48f0588ddfa674c643a", + "source_date_epoch": 1792562188, "builder_id": "radroots_sdk_artifact_v1", "features": [] } diff --git a/contracts/provenance/sdk/typescript.json b/contracts/provenance/sdk/typescript.json @@ -10,12 +10,12 @@ "files": [], "provenance": { "repository": "https://github.com/radrootslabs/lib", - "revision": "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", + "revision": "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", "architecture": "radroots.crates.release.v2", - "catalog_sha256": "1e679431ad70a024affc52e6c71151459aca41707429dd8015d014d27e5f40b6", - "lockfile_sha256": "c46a2552ecc6632625064333edb96aff26fe8b3560fa7e293c1aa25fda326db1", - "source_archive_sha256": "3b27bbb1cacd5329b9c7f2f7f7bf8c826e6f06625ad8f6520f6e5e8e4278b54a", - "source_date_epoch": 1792224313, + "catalog_sha256": "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8", + "lockfile_sha256": "273129eb54f7c1f2da2ecbcdb874c862bf6966f98bd21de30b9bc0a8cd3375fd", + "source_archive_sha256": "b38794a617927c6f891af234dc8ef6f43ac25b47df39f48f0588ddfa674c643a", + "source_date_epoch": 1792562188, "builder_id": "radroots_sdk_artifact_v1", "features": [] } diff --git a/contracts/provenance/sdk/wasm.json b/contracts/provenance/sdk/wasm.json @@ -10,12 +10,12 @@ "files": [], "provenance": { "repository": "https://github.com/radrootslabs/lib", - "revision": "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4", + "revision": "3d9f666bf9e9f66d1ade4293c516f03c88caf35a", "architecture": "radroots.crates.release.v2", - "catalog_sha256": "1e679431ad70a024affc52e6c71151459aca41707429dd8015d014d27e5f40b6", - "lockfile_sha256": "c46a2552ecc6632625064333edb96aff26fe8b3560fa7e293c1aa25fda326db1", - "source_archive_sha256": "3b27bbb1cacd5329b9c7f2f7f7bf8c826e6f06625ad8f6520f6e5e8e4278b54a", - "source_date_epoch": 1792224313, + "catalog_sha256": "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8", + "lockfile_sha256": "273129eb54f7c1f2da2ecbcdb874c862bf6966f98bd21de30b9bc0a8cd3375fd", + "source_archive_sha256": "b38794a617927c6f891af234dc8ef6f43ac25b47df39f48f0588ddfa674c643a", + "source_date_epoch": 1792562188, "builder_id": "radroots_sdk_artifact_v1", "features": [] } diff --git a/generated/kotlin/source.lock b/generated/kotlin/source.lock @@ -2,11 +2,11 @@ "schema_version": 1, "source_package": "radroots_sdk_ffi", "source_version": "0.1.0-alpha", - "source_sha256": "d8b1391c6f58ef35d9abefb005b6adabf3b424fadc3a615180a9df75fb55b0b5", - "generator": "uniffi", - "generator_version": "0.29.5", + "source_sha256": "ff679e85748e0872694dac745522801997d192774f77238ec050379027d1fb70", + "generator": "radroots_ffi_bindgen", + "generator_version": "0.32.2+radroots-native-v2", "language": "kotlin", "outputs": { - "uniffi/radroots_sdk/radroots_sdk.kt": "cc57260fade24a3b6d8366f06f17fb2d3132a0293cb61dd2a12d30d95f4a4e66" + "uniffi/radroots_sdk/radroots_sdk.kt": "7d7a4955138d226ed0a73bb9070e34c585be4c2d11cc8e9b4f430ccbbebbfc55" } } diff --git a/generated/kotlin/uniffi/radroots_sdk/radroots_sdk.kt b/generated/kotlin/uniffi/radroots_sdk/radroots_sdk.kt @@ -66,7 +66,7 @@ open class RustBuffer : Structure() { companion object { internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status -> // Note: need to convert the size to a `Long` value to make this work with JVM. - UniffiLib.INSTANCE.ffi_radroots_sdk_ffi_rustbuffer_alloc(size.toLong(), status) + UniffiLib.ffi_radroots_sdk_ffi_rustbuffer_alloc(size.toLong(), status) }.also { if(it.data == null) { throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") @@ -82,51 +82,17 @@ open class RustBuffer : Structure() { } internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status -> - UniffiLib.INSTANCE.ffi_radroots_sdk_ffi_rustbuffer_free(buf, status) + UniffiLib.ffi_radroots_sdk_ffi_rustbuffer_free(buf, status) } } @Suppress("TooGenericExceptionThrown") fun asByteBuffer() = - this.data?.getByteBuffer(0, this.len.toLong())?.also { + this.data?.getByteBuffer(0, this.len)?.also { it.order(ByteOrder.BIG_ENDIAN) } } -/** - * The equivalent of the `*mut RustBuffer` type. - * Required for callbacks taking in an out pointer. - * - * Size is the sum of all values in the struct. - * - * @suppress - */ -class RustBufferByReference : ByReference(16) { - /** - * Set the pointed-to `RustBuffer` to the given value. - */ - fun setValue(value: RustBuffer.ByValue) { - // NOTE: The offsets are as they are in the C-like struct. - val pointer = getPointer() - pointer.setLong(0, value.capacity) - pointer.setLong(8, value.len) - pointer.setPointer(16, value.data) - } - - /** - * Get a `RustBuffer.ByValue` from this reference. - */ - fun getValue(): RustBuffer.ByValue { - val pointer = getPointer() - val value = RustBuffer.ByValue() - value.writeField("capacity", pointer.getLong(0)) - value.writeField("len", pointer.getLong(8)) - value.writeField("data", pointer.getLong(16)) - - return value - } -} - // This is a helper for safely passing byte references into the rust code. // It's not actually used at the moment, because there aren't many things that you // can take a direct pointer to in the JVM, and if we're going to copy something @@ -140,6 +106,43 @@ internal open class ForeignBytes : Structure() { class ByValue : ForeignBytes(), Structure.ByValue } + +// Converter for `&[u8]` / `[ByRef] bytes` arguments. +// +// Only `lower` is valid — zero-copy byte buffers only flow foreign -> Rust, +// and only in argument position. `lift`, `read`, `write`, and +// `allocationSize` have no sound implementation here and all panic at +// runtime. The `FfiConverter` interface is implemented so that the +// compiler enforces the full method set (rather than relying on eyeball). +// +// The provided `ByteBuffer` MUST be direct — only direct buffers have a +// stable native address that JNA can expose via `getDirectBufferPointer`. +// The returned `ForeignBytes.ByValue` is only valid for the duration of +// the FFI call; the Rust side treats it as a borrow. +internal object FfiConverterByRefBytes : FfiConverter<java.nio.ByteBuffer, ForeignBytes.ByValue> { + override fun lower(value: java.nio.ByteBuffer): ForeignBytes.ByValue { + require(value.isDirect) { "UniFFI zero-copy &[u8] requires a direct ByteBuffer. Use ByteBuffer.allocateDirect()." } + val remaining = value.remaining() + val fb = ForeignBytes.ByValue() + fb.len = remaining + // Zero-length direct buffers: skip getDirectBufferPointer (platform-variable behavior) + // and pass null. The Rust side treats (null, 0) as &[]. + fb.data = if (remaining == 0) null else com.sun.jna.Native.getDirectBufferPointer(value) + return fb + } + + override fun lift(value: ForeignBytes.ByValue): java.nio.ByteBuffer = + error("ByRef bytes cannot be lifted: zero-copy &[u8] only flows foreign->Rust") + + override fun read(buf: java.nio.ByteBuffer): java.nio.ByteBuffer = + error("ByRef bytes cannot be read from a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.") + + override fun write(value: java.nio.ByteBuffer, buf: java.nio.ByteBuffer): Unit = + error("ByRef bytes cannot be written to a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.") + + override fun allocationSize(value: java.nio.ByteBuffer): ULong = + error("ByRef bytes have no RustBuffer allocation size: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.") +} /** * The FfiConverter interface handles converter types to and from the FFI * @@ -323,8 +326,9 @@ internal inline fun<T> uniffiTraitInterfaceCall( try { writeReturn(makeCall()) } catch(e: kotlin.Exception) { + val err = try { e.stackTraceToString() } catch(_: Throwable) { "" } callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR - callStatus.error_buf = FfiConverterString.lower(e.toString()) + callStatus.error_buf = FfiConverterString.lower(err) } } @@ -341,28 +345,41 @@ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError( callStatus.code = UNIFFI_CALL_ERROR callStatus.error_buf = lowerError(e) } else { + val err = try { e.stackTraceToString() } catch(_: Throwable) { "" } callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR - callStatus.error_buf = FfiConverterString.lower(e.toString()) + callStatus.error_buf = FfiConverterString.lower(err) } } } +// Initial value and increment amount for handles. +// These ensure that Kotlin-generated handles always have the lowest bit set +private const val UNIFFI_HANDLEMAP_INITIAL = 1.toLong() +private const val UNIFFI_HANDLEMAP_DELTA = 2.toLong() + // Map handles to objects // // This is used pass an opaque 64-bit handle representing a foreign object to the Rust code. internal class UniffiHandleMap<T: Any> { private val map = ConcurrentHashMap<Long, T>() - private val counter = java.util.concurrent.atomic.AtomicLong(0) + // Start + private val counter = java.util.concurrent.atomic.AtomicLong(UNIFFI_HANDLEMAP_INITIAL) val size: Int get() = map.size // Insert a new object into the handle map and get a handle for it fun insert(obj: T): Long { - val handle = counter.getAndAdd(1) + val handle = counter.getAndAdd(UNIFFI_HANDLEMAP_DELTA) map.put(handle, obj) return handle } + // Clone a handle, creating a new one + fun clone(handle: Long): Long { + val obj = map.get(handle) ?: throw InternalException("UniffiHandleMap.clone: Invalid handle") + return insert(obj) + } + // Get an object from the handle map fun get(handle: Long): T { return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle") @@ -385,357 +402,264 @@ private fun findLibraryName(componentName: String): String { return "radroots_sdk_ffi" } -private inline fun <reified Lib : Library> loadIndirect( - componentName: String -): Lib { - return Native.load<Lib>(findLibraryName(componentName), Lib::class.java) -} - // Define FFI callback types internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback { fun callback(`data`: Long,`pollResult`: Byte,) } -internal interface UniffiForeignFutureFree : com.sun.jna.Callback { +internal interface UniffiForeignFutureDroppedCallback : com.sun.jna.Callback { fun callback(`handle`: Long,) } internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback { fun callback(`handle`: Long,) } +internal interface UniffiCallbackInterfaceClone : com.sun.jna.Callback { + fun callback(`handle`: Long,) + : Long +} @Structure.FieldOrder("handle", "free") -internal open class UniffiForeignFuture( +internal open class UniffiForeignFutureDroppedCallbackStruct( @JvmField internal var `handle`: Long = 0.toLong(), - @JvmField internal var `free`: UniffiForeignFutureFree? = null, + @JvmField internal var `free`: UniffiForeignFutureDroppedCallback? = null, ) : Structure() { class UniffiByValue( `handle`: Long = 0.toLong(), - `free`: UniffiForeignFutureFree? = null, - ): UniffiForeignFuture(`handle`,`free`,), Structure.ByValue + `free`: UniffiForeignFutureDroppedCallback? = null, + ): UniffiForeignFutureDroppedCallbackStruct(`handle`,`free`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFuture) { + internal fun uniffiSetValue(other: UniffiForeignFutureDroppedCallbackStruct) { `handle` = other.`handle` `free` = other.`free` } } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructU8( +internal open class UniffiForeignFutureResultU8( @JvmField internal var `returnValue`: Byte = 0.toByte(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Byte = 0.toByte(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructU8(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultU8(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultU8) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU8.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU8.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructI8( +internal open class UniffiForeignFutureResultI8( @JvmField internal var `returnValue`: Byte = 0.toByte(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Byte = 0.toByte(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructI8(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultI8(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultI8) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI8.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI8.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructU16( +internal open class UniffiForeignFutureResultU16( @JvmField internal var `returnValue`: Short = 0.toShort(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Short = 0.toShort(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructU16(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultU16(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultU16) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU16.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU16.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructI16( +internal open class UniffiForeignFutureResultI16( @JvmField internal var `returnValue`: Short = 0.toShort(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Short = 0.toShort(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructI16(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultI16(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultI16) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI16.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI16.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructU32( +internal open class UniffiForeignFutureResultU32( @JvmField internal var `returnValue`: Int = 0, @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Int = 0, `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructU32(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultU32(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultU32) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU32.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU32.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructI32( +internal open class UniffiForeignFutureResultI32( @JvmField internal var `returnValue`: Int = 0, @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Int = 0, `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructI32(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultI32(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultI32) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI32.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI32.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructU64( +internal open class UniffiForeignFutureResultU64( @JvmField internal var `returnValue`: Long = 0.toLong(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Long = 0.toLong(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructU64(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultU64(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultU64) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU64.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU64.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructI64( +internal open class UniffiForeignFutureResultI64( @JvmField internal var `returnValue`: Long = 0.toLong(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Long = 0.toLong(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructI64(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultI64(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultI64) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI64.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI64.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructF32( +internal open class UniffiForeignFutureResultF32( @JvmField internal var `returnValue`: Float = 0.0f, @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Float = 0.0f, `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructF32(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultF32(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultF32) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF32.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF32.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructF64( +internal open class UniffiForeignFutureResultF64( @JvmField internal var `returnValue`: Double = 0.0, @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: Double = 0.0, `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructF64(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultF64(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultF64) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF64.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF64.UniffiByValue,) } @Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructPointer( - @JvmField internal var `returnValue`: Pointer = Pointer.NULL, - @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), -) : Structure() { - class UniffiByValue( - `returnValue`: Pointer = Pointer.NULL, - `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructPointer(`returnValue`,`callStatus`,), Structure.ByValue - - internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) { - `returnValue` = other.`returnValue` - `callStatus` = other.`callStatus` - } - -} -internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructPointer.UniffiByValue,) -} -@Structure.FieldOrder("returnValue", "callStatus") -internal open class UniffiForeignFutureStructRustBuffer( +internal open class UniffiForeignFutureResultRustBuffer( @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(), `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultRustBuffer) { `returnValue` = other.`returnValue` `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultRustBuffer.UniffiByValue,) } @Structure.FieldOrder("callStatus") -internal open class UniffiForeignFutureStructVoid( +internal open class UniffiForeignFutureResultVoid( @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), ) : Structure() { class UniffiByValue( `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(), - ): UniffiForeignFutureStructVoid(`callStatus`,), Structure.ByValue + ): UniffiForeignFutureResultVoid(`callStatus`,), Structure.ByValue - internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) { + internal fun uniffiSetValue(other: UniffiForeignFutureResultVoid) { `callStatus` = other.`callStatus` } } internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { - fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructVoid.UniffiByValue,) + fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultVoid.UniffiByValue,) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// A JNA Library to expose the extern-C FFI definitions. +// This is an implementation detail which will be called internally by the public API. // For large crates we prevent `MethodTooLargeException` (see #2340) // N.B. the name of the extension is very misleading, since it is @@ -743,218 +667,188 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { // in the interface for large crates. // // By splitting the otherwise huge interface into two parts -// * UniffiLib -// * IntegrityCheckingUniffiLib (this) +// * UniffiLib (this) +// * IntegrityCheckingUniffiLib +// And all checksum methods are put into `IntegrityCheckingUniffiLib` // we allow for ~2x as many methods in the UniffiLib interface. // -// The `ffi_uniffi_contract_version` method and all checksum methods are put -// into `IntegrityCheckingUniffiLib` and these methods are called only once, -// when the library is loaded. -internal interface IntegrityCheckingUniffiLib : Library { - // Integrity check functions only - fun uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report( -): Short -fun uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest( -): Short -fun uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation( -): Short -fun uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation( -): Short -fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities( -): Short -fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close( -): Short -fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed( -): Short -fun uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory( -): Short -fun ffi_radroots_sdk_ffi_uniffi_contract_version( -): Int +// Note: above all written when we used JNA's `loadIndirect` etc. +// We now use JNA's "direct mapping" - unclear if same considerations apply exactly. +internal object IntegrityCheckingUniffiLib { + init { + Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "radroots_sdk")) + uniffiCheckContractApiVersion(this) + uniffiCheckApiChecksums(this) + } + + internal fun ensureInitialized() = Unit + external fun uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed( + ): Int + external fun uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory( + ): Int + external fun ffi_radroots_sdk_ffi_uniffi_contract_version( + ): Int + + +} + +internal object UniffiLib { + + // The Cleaner for the whole library + internal val CLEANER: UniffiCleaner by lazy { + UniffiCleaner.create() + } + + + init { + Native.register(UniffiLib::class.java, findLibraryName(componentName = "radroots_sdk")) + + } + + internal fun ensureInitialized() = Unit + external fun uniffi_radroots_sdk_ffi_fn_clone_mobileclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Long + external fun uniffi_radroots_sdk_ffi_fn_free_mobileclient(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Unit + external fun uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(uniffi_out_err: UniffiRustCallStatus, + ): Long + external fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_close(`ptr`: Long, + ): Long + external fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Byte + external fun uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report(`canonicalContent`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest(`canonicalBytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation(`canonicalContent`: RustBuffer.ByValue,`createdAtUnixS`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation(`event`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun ffi_radroots_sdk_ffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun ffi_radroots_sdk_ffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun ffi_radroots_sdk_ffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Unit + external fun ffi_radroots_sdk_ffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun ffi_radroots_sdk_ffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_u8(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_u8(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + external fun ffi_radroots_sdk_ffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_i8(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_i8(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Byte + external fun ffi_radroots_sdk_ffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_u16(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_u16(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + external fun ffi_radroots_sdk_ffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_i16(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_i16(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Short + external fun ffi_radroots_sdk_ffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_u32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_u32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + external fun ffi_radroots_sdk_ffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_i32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_i32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + external fun ffi_radroots_sdk_ffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_u64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_u64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Long + external fun ffi_radroots_sdk_ffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_i64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_i64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Long + external fun ffi_radroots_sdk_ffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_f32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_f32(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Float + external fun ffi_radroots_sdk_ffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_f64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_f64(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Double + external fun ffi_radroots_sdk_ffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_rust_buffer(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_rust_buffer(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + external fun ffi_radroots_sdk_ffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_cancel_void(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_free_void(`handle`: Long, + ): Unit + external fun ffi_radroots_sdk_ffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Unit -} - -// A JNA Library to expose the extern-C FFI definitions. -// This is an implementation detail which will be called internally by the public API. -internal interface UniffiLib : Library { - companion object { - internal val INSTANCE: UniffiLib by lazy { - val componentName = "radroots_sdk" - // For large crates we prevent `MethodTooLargeException` (see #2340) - // N.B. the name of the extension is very misleading, since it is - // rather `InterfaceTooLargeException`, caused by too many methods - // in the interface for large crates. - // - // By splitting the otherwise huge interface into two parts - // * UniffiLib (this) - // * IntegrityCheckingUniffiLib - // And all checksum methods are put into `IntegrityCheckingUniffiLib` - // we allow for ~2x as many methods in the UniffiLib interface. - // - // Thus we first load the library with `loadIndirect` as `IntegrityCheckingUniffiLib` - // so that we can (optionally!) call `uniffiCheckApiChecksums`... - loadIndirect<IntegrityCheckingUniffiLib>(componentName) - .also { lib: IntegrityCheckingUniffiLib -> - uniffiCheckContractApiVersion(lib) - uniffiCheckApiChecksums(lib) - } - // ... and then we load the library as `UniffiLib` - // N.B. we cannot use `loadIndirect` once and then try to cast it to `UniffiLib` - // => results in `java.lang.ClassCastException: com.sun.proxy.$Proxy cannot be cast to ...` - // error. So we must call `loadIndirect` twice. For crates large enough - // to trigger this issue, the performance impact is negligible, running on - // a macOS M1 machine the `loadIndirect` call takes ~50ms. - val lib = loadIndirect<UniffiLib>(componentName) - // No need to check the contract version and checksums, since - // we already did that with `IntegrityCheckingUniffiLib` above. - // Loading of library with integrity check done. - lib - } - - // The Cleaner for the whole library - internal val CLEANER: UniffiCleaner by lazy { - UniffiCleaner.create() - } - } - - // FFI functions - fun uniffi_radroots_sdk_ffi_fn_clone_mobileclient(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Pointer -fun uniffi_radroots_sdk_ffi_fn_free_mobileclient(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Unit -fun uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(uniffi_out_err: UniffiRustCallStatus, -): Pointer -fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_close(`ptr`: Pointer, -): Long -fun uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, -): Byte -fun uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report(`canonicalContent`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest(`canonicalBytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation(`canonicalContent`: RustBuffer.ByValue,`createdAtUnixS`: Long,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation(`event`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun ffi_radroots_sdk_ffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun ffi_radroots_sdk_ffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun ffi_radroots_sdk_ffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, -): Unit -fun ffi_radroots_sdk_ffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun ffi_radroots_sdk_ffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_u8(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_u8(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Byte -fun ffi_radroots_sdk_ffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_i8(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_i8(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Byte -fun ffi_radroots_sdk_ffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_u16(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_u16(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Short -fun ffi_radroots_sdk_ffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_i16(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_i16(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Short -fun ffi_radroots_sdk_ffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_u32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_u32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Int -fun ffi_radroots_sdk_ffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_i32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_i32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Int -fun ffi_radroots_sdk_ffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_u64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_u64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Long -fun ffi_radroots_sdk_ffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_i64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_i64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Long -fun ffi_radroots_sdk_ffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_f32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_f32(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Float -fun ffi_radroots_sdk_ffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_f64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_f64(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Double -fun ffi_radroots_sdk_ffi_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_pointer(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_pointer(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Pointer -fun ffi_radroots_sdk_ffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_rust_buffer(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_rust_buffer(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): RustBuffer.ByValue -fun ffi_radroots_sdk_ffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_cancel_void(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_free_void(`handle`: Long, -): Unit -fun ffi_radroots_sdk_ffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, -): Unit } private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) { // Get the bindings contract version from our ComponentInterface - val bindings_contract_version = 29 + val bindings_contract_version = 30 // Get the scaffolding contract version by calling the into the dylib val scaffolding_contract_version = lib.ffi_radroots_sdk_ffi_uniffi_contract_version() if (bindings_contract_version != scaffolding_contract_version) { @@ -963,28 +857,28 @@ private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) { } @Suppress("UNUSED_PARAMETER") private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { - if (lib.uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report() != 37549.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report() and 0xFFFF) != 10431) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest() != 35922.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest() and 0xFFFF) != 17039) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation() != 53127.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation() and 0xFFFF) != 35556) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation() != 46555.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation() and 0xFFFF) != 64772) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities() != 23938.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities() and 0xFFFF) != 35060) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close() != 15210.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close() and 0xFFFF) != 34026) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed() != 40205.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed() and 0xFFFF) != 56426) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory() != 50243.toShort()) { + if ((lib.uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory() and 0xFFFF) != 5837) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } } @@ -993,14 +887,17 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { * @suppress */ public fun uniffiEnsureInitialized() { - UniffiLib.INSTANCE + // Call arbitrary methods on IntegrityCheckingUniffiLib and UniffiLib to ensure that + // their init blocks run. This ensures initialization across crates works as expected. + IntegrityCheckingUniffiLib.ensureInitialized() + UniffiLib.ensureInitialized() } // Async support // Async return type handlers internal const val UNIFFI_RUST_FUTURE_POLL_READY = 0.toByte() -internal const val UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1.toByte() +internal const val UNIFFI_RUST_FUTURE_POLL_WAKE = 1.toByte() internal val uniffiContinuationHandleMap = UniffiHandleMap<CancellableContinuation<Byte>>() @@ -1100,11 +997,22 @@ inline fun <T : Disposable?, R> T.use(block: (T) -> R) = } /** + * Placeholder object used to signal that we're constructing an interface with a FFI handle. + * + * This is the first argument for interface constructors that input a raw handle. It exists is that + * so we can avoid signature conflicts when an interface has a regular constructor than inputs a + * Long. + * + * @suppress + * */ +object UniffiWithHandle + +/** * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly. * * @suppress * */ -object NoPointer +object NoHandle /** * The cleaner interface for Object finalization code to run. * This is the entry point to any implementation that we're using. @@ -1178,6 +1086,10 @@ public object FfiConverterUShort: FfiConverter<UShort, Short> { return value.toUShort() } + fun lift(value: Int): UShort { + return value.toUShort() + } + override fun read(buf: ByteBuffer): UShort { return lift(buf.getShort()) } @@ -1339,21 +1251,18 @@ public object FfiConverterByteArray: FfiConverterRustBuffer<ByteArray> { } -// This template implements a class for working with a Rust struct via a Pointer/Arc<T> +// This template implements a class for working with a Rust struct via a handle // to the live Rust struct on the other side of the FFI. // -// Each instance implements core operations for working with the Rust `Arc<T>` and the -// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. -// // There's some subtlety here, because we have to be careful not to operate on a Rust // struct after it has been dropped, and because we must expose a public API for freeing // theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: // -// * Each instance holds an opaque pointer to the underlying Rust struct. -// Method calls need to read this pointer from the object's state and pass it in to +// * Each instance holds an opaque handle to the underlying Rust struct. +// Method calls need to read this handle from the object's state and pass it in to // the Rust FFI. // -// * When an instance is no longer needed, its pointer should be passed to a +// * When an instance is no longer needed, its handle should be passed to a // special destructor function provided by the Rust FFI, which will drop the // underlying Rust struct. // @@ -1378,13 +1287,13 @@ public object FfiConverterByteArray: FfiConverterRustBuffer<ByteArray> { // 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, // or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). // -// If we try to implement this with mutual exclusion on access to the pointer, there is the +// If we try to implement this with mutual exclusion on access to the handle, there is the // possibility of a race between a method call and a concurrent call to `destroy`: // -// * Thread A starts a method call, reads the value of the pointer, but is interrupted -// before it can pass the pointer over the FFI to Rust. +// * Thread A starts a method call, reads the value of the handle, but is interrupted +// before it can pass the handle over the FFI to Rust. // * Thread B calls `destroy` and frees the underlying Rust struct. -// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// * Thread A resumes, passing the already-read handle value to Rust and triggering // a use-after-free. // // One possible solution would be to use a `ReadWriteLock`, with each method call taking @@ -1463,48 +1372,55 @@ public interface MobileClientInterface { /** * Thread-safe mobile handle delegating lifecycle to [`radroots_sdk::Client`]. */ -open class MobileClient: Disposable, AutoCloseable, MobileClientInterface +open class MobileClient: Disposable, MobileClientInterface { - constructor(pointer: Pointer) { - this.pointer = pointer - this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + @Suppress("UNUSED_PARAMETER") + /** + * @suppress + */ + constructor(withHandle: UniffiWithHandle, handle: Long) { + this.handle = handle + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle)) } /** + * @suppress + * * This constructor can be used to instantiate a fake object. Only used for tests. Any * attempt to actually use an object constructed this way will fail as there is no * connected Rust object. */ @Suppress("UNUSED_PARAMETER") - constructor(noPointer: NoPointer) { - this.pointer = null - this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + constructor(noHandle: NoHandle) { + this.handle = 0 + this.cleanable = null } - protected val pointer: Pointer? - protected val cleanable: UniffiCleaner.Cleanable + protected val handle: Long + protected val cleanable: UniffiCleaner.Cleanable? private val wasDestroyed = AtomicBoolean(false) private val callCounter = AtomicLong(1) + /** + * Whether the current object has been destroyed and its reference is gone in the Rust side. + */ + val uniffiIsDestroyed: Boolean get() = wasDestroyed.get() + override fun destroy() { // Only allow a single call to this method. // TODO: maybe we should log a warning if called more than once? if (this.wasDestroyed.compareAndSet(false, true)) { // This decrement always matches the initial count of 1 given at creation time. if (this.callCounter.decrementAndGet() == 0L) { - cleanable.clean() + cleanable?.clean() } } } - @Synchronized - override fun close() { - this.destroy() - } - internal inline fun <R> callWithPointer(block: (ptr: Pointer) -> R): R { + internal inline fun <R> callWithHandle(block: (handle: Long) -> R): R { // Check and increment the call counter, to keep the object alive. // This needs a compare-and-set retry loop in case of concurrent updates. do { @@ -1516,32 +1432,40 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") } } while (! this.callCounter.compareAndSet(c, c + 1L)) - // Now we can safely do the method call without the pointer being freed concurrently. + // Now we can safely do the method call without the handle being freed concurrently. try { - return block(this.uniffiClonePointer()) + return block(this.uniffiCloneHandle()) } finally { // This decrement always matches the increment we performed above. if (this.callCounter.decrementAndGet() == 0L) { - cleanable.clean() + cleanable?.clean() } } } // Use a static inner class instead of a closure so as not to accidentally // capture `this` as part of the cleanable's action. - private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + private class UniffiCleanAction(private val handle: Long) : Runnable { override fun run() { - pointer?.let { ptr -> - uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_free_mobileclient(ptr, status) - } + if (handle == 0.toLong()) { + // Fake object created with `NoHandle`, don't try to free. + return; + } + uniffiRustCall { status -> + UniffiLib.uniffi_radroots_sdk_ffi_fn_free_mobileclient(handle, status) } } } - fun uniffiClonePointer(): Pointer { + /** + * @suppress + */ + fun uniffiCloneHandle(): Long { + if (handle == 0.toLong()) { + throw InternalException("uniffiCloneHandle() called on NoHandle object"); + } return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_clone_mobileclient(pointer!!, status) + UniffiLib.uniffi_radroots_sdk_ffi_fn_clone_mobileclient(handle, status) } } @@ -1550,10 +1474,11 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface * Returns stable capability DTOs without probing host resources. */override fun `capabilities`(): List<CapabilityStatus> { return FfiConverterSequenceTypeCapabilityStatus.lift( - callWithPointer { + callWithHandle { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities( - it, _status) + UniffiLib.uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities( + it, + _status) } } ) @@ -1568,17 +1493,17 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `close`() { return uniffiRustCallAsync( - callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_method_mobileclient_close( - thisPtr, + callWithHandle { uniffiHandle -> + UniffiLib.uniffi_radroots_sdk_ffi_fn_method_mobileclient_close( + uniffiHandle, ) }, - { future, callback, continuation -> UniffiLib.INSTANCE.ffi_radroots_sdk_ffi_rust_future_poll_void(future, callback, continuation) }, - { future, continuation -> UniffiLib.INSTANCE.ffi_radroots_sdk_ffi_rust_future_complete_void(future, continuation) }, - { future -> UniffiLib.INSTANCE.ffi_radroots_sdk_ffi_rust_future_free_void(future) }, + { future, callback, continuation -> UniffiLib.ffi_radroots_sdk_ffi_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_radroots_sdk_ffi_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_radroots_sdk_ffi_rust_future_free_void(future) }, // lift function - { Unit }, + { }, // Error FFI converter Exception.ErrorHandler, @@ -1590,10 +1515,11 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface * Returns whether explicit SDK close completed across all clones. */override fun `isClosed`(): kotlin.Boolean { return FfiConverterBoolean.lift( - callWithPointer { + callWithHandle { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed( - it, _status) + UniffiLib.uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed( + it, + _status) } } ) @@ -1603,6 +1529,9 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface + + + companion object { /** @@ -1611,7 +1540,8 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface @Throws(Exception::class) fun `memory`(): MobileClient { return FfiConverterTypeMobileClient.lift( uniffiRustCallWithError(Exception) { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory( + UniffiLib.uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory( + _status) } ) @@ -1623,31 +1553,27 @@ open class MobileClient: Disposable, AutoCloseable, MobileClientInterface } + /** * @suppress */ -public object FfiConverterTypeMobileClient: FfiConverter<MobileClient, Pointer> { - - override fun lower(value: MobileClient): Pointer { - return value.uniffiClonePointer() +public object FfiConverterTypeMobileClient: FfiConverter<MobileClient, Long> { + override fun lower(value: MobileClient): Long { + return value.uniffiCloneHandle() } - override fun lift(value: Pointer): MobileClient { - return MobileClient(value) + override fun lift(value: Long): MobileClient { + return MobileClient(UniffiWithHandle, value) } override fun read(buf: ByteBuffer): MobileClient { - // The Rust code always writes pointers as 8 bytes, and will - // fail to compile if they don't fit. - return lift(Pointer(buf.getLong())) + return lift(buf.getLong()) } override fun allocationSize(value: MobileClient) = 8UL override fun write(value: MobileClient, buf: ByteBuffer) { - // The Rust code always expects pointers written as 8 bytes, - // and will fail to compile if they don't fit. - buf.putLong(Pointer.nativeValue(lower(value))) + buf.putLong(lower(value)) } } @@ -1657,12 +1583,21 @@ public object FfiConverterTypeMobileClient: FfiConverter<MobileClient, Pointer> * Versioned, presentation-independent capability observation. */ data class CapabilityStatus ( - var `id`: kotlin.String, - var `compiled`: kotlin.Boolean, - var `configured`: kotlin.Boolean, - var `availability`: CapabilityAvailability, + var `id`: kotlin.String + , + var `compiled`: kotlin.Boolean + , + var `configured`: kotlin.Boolean + , + var `availability`: CapabilityAvailability + , var `maturity`: CapabilityMaturity -) { + +){ + + + + companion object } @@ -1704,16 +1639,29 @@ public object FfiConverterTypeCapabilityStatus: FfiConverterRustBuffer<Capabilit * Verified final RHI attestation projection. */ data class RhiEvidenceAttestation ( - var `issuerPubkey`: kotlin.String, - var `tradeId`: kotlin.String, - var `claimMutationId`: kotlin.String, - var `outcome`: TradeEvidenceOutcome, - var `observedAtUnixS`: kotlin.String, - var `tradeGeneration`: kotlin.String, - var `statementDigest`: kotlin.String, - var `supersession`: RhiEvidenceSupersession?, + var `issuerPubkey`: kotlin.String + , + var `tradeId`: kotlin.String + , + var `claimMutationId`: kotlin.String + , + var `outcome`: TradeEvidenceOutcome + , + var `observedAtUnixS`: kotlin.String + , + var `tradeGeneration`: kotlin.String + , + var `statementDigest`: kotlin.String + , + var `supersession`: RhiEvidenceSupersession? + , var `canonicalContent`: kotlin.String -) { + +){ + + + + companion object } @@ -1767,22 +1715,41 @@ public object FfiConverterTypeRhiEvidenceAttestation: FfiConverterRustBuffer<Rhi * Bounded projection of one canonical RHI evidence report. */ data class RhiEvidenceReport ( - var `contractId`: kotlin.String, - var `contractVersion`: kotlin.UShort, - var `issuerPubkey`: kotlin.String, - var `tradeId`: kotlin.String, - var `claimMutationId`: kotlin.String, - var `outcome`: TradeEvidenceOutcome, - var `reasonCodes`: List<kotlin.String>, - var `projectionDigest`: kotlin.String, - var `evidenceManifestDigest`: kotlin.String, - var `evidencePolicyDigest`: kotlin.String, - var `observedAtUnixS`: kotlin.String, - var `tradeGeneration`: kotlin.String, - var `statementDigest`: kotlin.String, - var `supersession`: RhiEvidenceSupersession?, + var `contractId`: kotlin.String + , + var `contractVersion`: kotlin.UShort + , + var `issuerPubkey`: kotlin.String + , + var `tradeId`: kotlin.String + , + var `claimMutationId`: kotlin.String + , + var `outcome`: TradeEvidenceOutcome + , + var `reasonCodes`: List<kotlin.String> + , + var `projectionDigest`: kotlin.String + , + var `evidenceManifestDigest`: kotlin.String + , + var `evidencePolicyDigest`: kotlin.String + , + var `observedAtUnixS`: kotlin.String + , + var `tradeGeneration`: kotlin.String + , + var `statementDigest`: kotlin.String + , + var `supersession`: RhiEvidenceSupersession? + , var `canonicalContent`: kotlin.String -) { + +){ + + + + companion object } @@ -1854,9 +1821,15 @@ public object FfiConverterTypeRhiEvidenceReport: FfiConverterRustBuffer<RhiEvide * Exact immutable RHI supersession reference. */ data class RhiEvidenceSupersession ( - var `reportId`: kotlin.String, + var `reportId`: kotlin.String + , var `eventId`: kotlin.String -) { + +){ + + + + companion object } @@ -1889,14 +1862,25 @@ public object FfiConverterTypeRhiEvidenceSupersession: FfiConverterRustBuffer<Rh * Signed NIP-01 event input for verified attestation admission. */ data class SignedEvent ( - var `id`: kotlin.String, - var `authorPubkey`: kotlin.String, - var `createdAtUnixS`: kotlin.ULong, - var `kind`: kotlin.UInt, - var `tags`: List<List<kotlin.String>>, - var `content`: kotlin.String, + var `id`: kotlin.String + , + var `authorPubkey`: kotlin.String + , + var `createdAtUnixS`: kotlin.ULong + , + var `kind`: kotlin.UInt + , + var `tags`: List<List<kotlin.String>> + , + var `content`: kotlin.String + , var `signature`: kotlin.String -) { + +){ + + + + companion object } @@ -1944,16 +1928,29 @@ public object FfiConverterTypeSignedEvent: FfiConverterRustBuffer<SignedEvent> { * Bounded projection of one canonical evidence manifest. */ data class TradeEvidenceManifest ( - var `contractId`: kotlin.String, - var `contractVersion`: kotlin.UShort, - var `tradeId`: kotlin.String, - var `tradeGeneration`: kotlin.String, - var `observedAtUnixS`: kotlin.String, - var `coverage`: TradeEvidenceCoverage, - var `evidencePolicyDigest`: kotlin.String, - var `manifestDigest`: kotlin.String, + var `contractId`: kotlin.String + , + var `contractVersion`: kotlin.UShort + , + var `tradeId`: kotlin.String + , + var `tradeGeneration`: kotlin.String + , + var `observedAtUnixS`: kotlin.String + , + var `coverage`: TradeEvidenceCoverage + , + var `evidencePolicyDigest`: kotlin.String + , + var `manifestDigest`: kotlin.String + , var `canonicalBytesHex`: kotlin.String -) { + +){ + + + + companion object } @@ -2007,14 +2004,25 @@ public object FfiConverterTypeTradeEvidenceManifest: FfiConverterRustBuffer<Trad * One unsigned typed event plan ready for host-owned signing. */ data class TypedEvidenceEventPlan ( - var `contractId`: kotlin.String, - var `kind`: kotlin.UInt, - var `authorPubkey`: kotlin.String, - var `createdAtUnixS`: kotlin.String, - var `expectedEventId`: kotlin.String, - var `tags`: List<List<kotlin.String>>, + var `contractId`: kotlin.String + , + var `kind`: kotlin.UInt + , + var `authorPubkey`: kotlin.String + , + var `createdAtUnixS`: kotlin.String + , + var `expectedEventId`: kotlin.String + , + var `tags`: List<List<kotlin.String>> + , var `content`: kotlin.String -) { + +){ + + + + companion object } @@ -2068,6 +2076,10 @@ enum class CapabilityAvailability { DEGRADED, UNAVAILABLE, UNSUPPORTED; + + + + companion object } @@ -2102,6 +2114,10 @@ enum class CapabilityMaturity { STABLE, PREVIEW, EXPERIMENTAL; + + + + companion object } @@ -2138,15 +2154,17 @@ sealed class Exception: kotlin.Exception() { val `code`: kotlin.String, - val `message`: kotlin.String, + override val `message`: kotlin.String, val `retryable`: kotlin.Boolean ) : Exception() { - override val message - get() = "code=${ `code` }, message=${ `message` }, retryable=${ `retryable` }" + } + + + companion object ErrorHandler : UniffiRustCallStatusErrorHandler<Exception> { override fun lift(error_buf: RustBuffer.ByValue): Exception = FfiConverterTypeError.lift(error_buf) } @@ -2209,6 +2227,10 @@ enum class TradeEvidenceCoverage { PARTIAL, SCOPE_SATISFIED, UNSUPPORTED; + + + + companion object } @@ -2243,6 +2265,10 @@ enum class TradeEvidenceOutcome { VALID, INVALID, INDETERMINATE; + + + + companion object } @@ -2392,7 +2418,9 @@ public object FfiConverterSequenceSequenceString: FfiConverterRustBuffer<List<Li @Throws(Exception::class) fun `parseRhiEvidenceReport`(`canonicalContent`: kotlin.String): RhiEvidenceReport { return FfiConverterTypeRhiEvidenceReport.lift( uniffiRustCallWithError(Exception) { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report( + UniffiLib.uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report( + + FfiConverterString.lower(`canonicalContent`),_status) } ) @@ -2402,7 +2430,9 @@ public object FfiConverterSequenceSequenceString: FfiConverterRustBuffer<List<Li @Throws(Exception::class) fun `parseTradeEvidenceManifest`(`canonicalBytes`: kotlin.ByteArray): TradeEvidenceManifest { return FfiConverterTypeTradeEvidenceManifest.lift( uniffiRustCallWithError(Exception) { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest( + UniffiLib.uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest( + + FfiConverterByteArray.lower(`canonicalBytes`),_status) } ) @@ -2412,8 +2442,11 @@ public object FfiConverterSequenceSequenceString: FfiConverterRustBuffer<List<Li @Throws(Exception::class) fun `prepareRhiEvidenceAttestation`(`canonicalContent`: kotlin.String, `createdAtUnixS`: kotlin.ULong): TypedEvidenceEventPlan { return FfiConverterTypeTypedEvidenceEventPlan.lift( uniffiRustCallWithError(Exception) { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation( - FfiConverterString.lower(`canonicalContent`),FfiConverterULong.lower(`createdAtUnixS`),_status) + UniffiLib.uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation( + + + FfiConverterString.lower(`canonicalContent`), + FfiConverterULong.lower(`createdAtUnixS`),_status) } ) } @@ -2422,7 +2455,9 @@ public object FfiConverterSequenceSequenceString: FfiConverterRustBuffer<List<Li @Throws(Exception::class) fun `validateRhiEvidenceAttestation`(`event`: SignedEvent): RhiEvidenceAttestation { return FfiConverterTypeRhiEvidenceAttestation.lift( uniffiRustCallWithError(Exception) { _status -> - UniffiLib.INSTANCE.uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation( + UniffiLib.uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation( + + FfiConverterTypeSignedEvent.lower(`event`),_status) } ) diff --git a/generated/swift/radroots_sdk.swift b/generated/swift/radroots_sdk.swift @@ -39,6 +39,52 @@ fileprivate extension ForeignBytes { init(bufferPointer: UnsafeBufferPointer<UInt8>) { self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) } + + init(rawBufferPointer: UnsafeRawBufferPointer) { + self.init( + len: Int32(rawBufferPointer.count), + data: rawBufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self) + ) + } +} + +// Converter for `&[u8]` / `[ByRef] bytes` arguments. +// +// Conforms to `FfiConverter` so the compiler enforces the full converter +// method set. Only the scope-bound `lower(_:_body:)` overload is sound — +// zero-copy byte buffers only flow foreign -> Rust, and only in argument +// position. The four protocol-witness methods (`lift`, `lower`, `read`, +// `write`) `fatalError` at runtime if anyone reaches them. +// +// The scope-bound `lower` takes a closure because the `ForeignBytes` +// pointer is only guaranteed valid for the duration of +// `Data.withUnsafeBytes`. Callers must run the full FFI call inside +// the closure body. +fileprivate enum FfiConverterByRefBytes: FfiConverter { + typealias SwiftType = Data + typealias FfiType = ForeignBytes + + static func lower<R>(_ value: Data, _ body: (ForeignBytes) throws -> R) rethrows -> R { + return try value.withUnsafeBytes { rawBuf in + try body(ForeignBytes(rawBufferPointer: rawBuf)) + } + } + + static func lower(_ value: Data) -> ForeignBytes { + fatalError("ByRef bytes cannot use the plain lower: returning ForeignBytes escapes the Data.withUnsafeBytes scope. Use the scope-bound lower(_:_body:) overload instead.") + } + + static func lift(_ value: ForeignBytes) throws -> Data { + fatalError("ByRef bytes cannot be lifted: zero-copy &[u8] only flows foreign->Rust") + } + + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { + fatalError("ByRef bytes cannot be read from a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.") + } + + static func write(_ value: Data, into buf: inout [UInt8]) { + fatalError("ByRef bytes cannot be written to a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.") + } } // For every type used in the interface, we provide helper methods for conveniently @@ -316,7 +362,7 @@ private func uniffiCheckCallStatus<E: Swift.Error>( } case CALL_CANCELLED: - fatalError("Cancellation not supported yet") + throw CancellationError() default: throw UniffiInternalError.unexpectedRustCallStatusCode @@ -352,21 +398,31 @@ private func uniffiTraitInterfaceCallWithError<T, E>( callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) } } +// Initial value and increment amount for handles. +// These ensure that SWIFT handles always have the lowest bit set +fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1 +fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2 + fileprivate final class UniffiHandleMap<T>: @unchecked Sendable { // All mutation happens with this lock held, which is why we implement @unchecked Sendable. private let lock = NSLock() private var map: [UInt64: T] = [:] - private var currentHandle: UInt64 = 1 + private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL func insert(obj: T) -> UInt64 { lock.withLock { - let handle = currentHandle - currentHandle += 1 - map[handle] = obj - return handle + return doInsert(obj) } } + // Low-level insert function, this assumes `lock` is held. + private func doInsert(_ obj: T) -> UInt64 { + let handle = currentHandle + currentHandle += UNIFFI_HANDLEMAP_DELTA + map[handle] = obj + return handle + } + func get(handle: UInt64) throws -> T { try lock.withLock { guard let obj = map[handle] else { @@ -376,6 +432,15 @@ fileprivate final class UniffiHandleMap<T>: @unchecked Sendable { } } + func clone(handle: UInt64) throws -> UInt64 { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return doInsert(obj) + } + } + @discardableResult func remove(handle: UInt64) throws -> T { try lock.withLock { @@ -484,7 +549,11 @@ fileprivate struct FfiConverterString: FfiConverter { return String() } let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len)) - return String(bytes: bytes, encoding: String.Encoding.utf8)! + // Use Swift's native UTF-8 decoder; `String(bytes:encoding:.utf8)` goes + // through Foundation's NSString and silently strips a leading U+FEFF BOM. + // Invalid UTF-8 substitutes U+FFFD instead of trapping (unreachable + // given Rust's `String` invariant). + return String(decoding: bytes, as: UTF8.self) } public static func lower(_ value: String) -> RustBuffer { @@ -500,7 +569,8 @@ fileprivate struct FfiConverterString: FfiConverter { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { let len: Int32 = try readInt(&buf) - return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + // See `lift` above for why we avoid Foundation's NSString-backed decoder here. + return String(decoding: try readBytes(&buf, count: Int(len)), as: UTF8.self) } public static func write(_ value: String, into buf: inout [UInt8]) { @@ -556,13 +626,13 @@ public protocol MobileClientProtocol: AnyObject, Sendable { * Thread-safe mobile handle delegating lifecycle to [`radroots_sdk::Client`]. */ open class MobileClient: MobileClientProtocol, @unchecked Sendable { - fileprivate let pointer: UnsafeMutableRawPointer! + fileprivate let handle: UInt64 - /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. #if swift(>=5.8) @_documentation(visibility: private) #endif - public struct NoPointer { + public struct NoHandle { public init() {} } @@ -572,36 +642,37 @@ open class MobileClient: MobileClientProtocol, @unchecked Sendable { #if swift(>=5.8) @_documentation(visibility: private) #endif - required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle } // This constructor can be used to instantiate a fake object. - // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. // // - Warning: - // 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. + // 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. #if swift(>=5.8) @_documentation(visibility: private) #endif - public init(noPointer: NoPointer) { - self.pointer = nil + public init(noHandle: NoHandle) { + self.handle = 0 } #if swift(>=5.8) @_documentation(visibility: private) #endif - public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_radroots_sdk_ffi_fn_clone_mobileclient(self.pointer, $0) } + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_radroots_sdk_ffi_fn_clone_mobileclient(self.handle, $0) } } // No primary constructor declared for this class. deinit { - guard let pointer = pointer else { + if handle == 0 { + // Mock objects have handle=0 don't try to free them return } - try! rustCall { uniffi_radroots_sdk_ffi_fn_free_mobileclient(pointer, $0) } + try! rustCall { uniffi_radroots_sdk_ffi_fn_free_mobileclient(handle, $0) } } @@ -610,7 +681,8 @@ open class MobileClient: MobileClientProtocol, @unchecked Sendable { */ public static func memory()throws -> MobileClient { return try FfiConverterTypeMobileClient_lift(try rustCallWithError(FfiConverterTypeError_lift) { - uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory($0 + uniffiCallStatus in + uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(uniffiCallStatus ) }) } @@ -622,7 +694,9 @@ public static func memory()throws -> MobileClient { */ open func capabilities() -> [CapabilityStatus] { return try! FfiConverterSequenceTypeCapabilityStatus.lift(try! rustCall() { - uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(self.uniffiClonePointer(),$0 + uniffiCallStatus in + uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities( + self.uniffiCloneHandle(),uniffiCallStatus ) }) } @@ -635,12 +709,12 @@ open func close()async throws { try await uniffiRustCallAsync( rustFutureFunc: { uniffi_radroots_sdk_ffi_fn_method_mobileclient_close( - self.uniffiClonePointer() - + self.uniffiCloneHandle() ) }, pollFunc: ffi_radroots_sdk_ffi_rust_future_poll_void, completeFunc: ffi_radroots_sdk_ffi_rust_future_complete_void, + cancelFunc: ffi_radroots_sdk_ffi_rust_future_cancel_void, freeFunc: ffi_radroots_sdk_ffi_rust_future_free_void, liftFunc: { $0 }, errorHandler: FfiConverterTypeError_lift @@ -652,12 +726,15 @@ open func close()async throws { */ open func isClosed() -> Bool { return try! FfiConverterBool.lift(try! rustCall() { - uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(self.uniffiClonePointer(),$0 + uniffiCallStatus in + uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed( + self.uniffiCloneHandle(),uniffiCallStatus ) }) } + } @@ -665,33 +742,24 @@ open func isClosed() -> Bool { @_documentation(visibility: private) #endif public struct FfiConverterTypeMobileClient: FfiConverter { - - typealias FfiType = UnsafeMutableRawPointer + typealias FfiType = UInt64 typealias SwiftType = MobileClient - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MobileClient { - return MobileClient(unsafeFromRawPointer: pointer) + public static func lift(_ handle: UInt64) throws -> MobileClient { + return MobileClient(unsafeFromHandle: handle) } - public static func lower(_ value: MobileClient) -> UnsafeMutableRawPointer { - return value.uniffiClonePointer() + public static func lower(_ value: MobileClient) -> UInt64 { + return value.uniffiCloneHandle() } public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MobileClient { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) + let handle: UInt64 = try readInt(&buf) + return try lift(handle) } public static func write(_ value: MobileClient, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + writeInt(&buf, lower(value)) } } @@ -699,14 +767,14 @@ public struct FfiConverterTypeMobileClient: FfiConverter { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeMobileClient_lift(_ pointer: UnsafeMutableRawPointer) throws -> MobileClient { - return try FfiConverterTypeMobileClient.lift(pointer) +public func FfiConverterTypeMobileClient_lift(_ handle: UInt64) throws -> MobileClient { + return try FfiConverterTypeMobileClient.lift(handle) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeMobileClient_lower(_ value: MobileClient) -> UnsafeMutableRawPointer { +public func FfiConverterTypeMobileClient_lower(_ value: MobileClient) -> UInt64 { return FfiConverterTypeMobileClient.lower(value) } @@ -716,7 +784,7 @@ public func FfiConverterTypeMobileClient_lower(_ value: MobileClient) -> UnsafeM /** * Versioned, presentation-independent capability observation. */ -public struct CapabilityStatus { +public struct CapabilityStatus: Equatable, Hashable { public var id: String public var compiled: Bool public var configured: Bool @@ -732,43 +800,15 @@ public struct CapabilityStatus { self.availability = availability self.maturity = maturity } -} -#if compiler(>=6) -extension CapabilityStatus: Sendable {} -#endif -extension CapabilityStatus: Equatable, Hashable { - public static func ==(lhs: CapabilityStatus, rhs: CapabilityStatus) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.compiled != rhs.compiled { - return false - } - if lhs.configured != rhs.configured { - return false - } - if lhs.availability != rhs.availability { - return false - } - if lhs.maturity != rhs.maturity { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(compiled) - hasher.combine(configured) - hasher.combine(availability) - hasher.combine(maturity) - } } - +#if compiler(>=6) +extension CapabilityStatus: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -813,7 +853,7 @@ public func FfiConverterTypeCapabilityStatus_lower(_ value: CapabilityStatus) -> /** * Verified final RHI attestation projection. */ -public struct RhiEvidenceAttestation { +public struct RhiEvidenceAttestation: Equatable, Hashable { public var issuerPubkey: String public var tradeId: String public var claimMutationId: String @@ -837,59 +877,15 @@ public struct RhiEvidenceAttestation { self.supersession = supersession self.canonicalContent = canonicalContent } -} -#if compiler(>=6) -extension RhiEvidenceAttestation: Sendable {} -#endif -extension RhiEvidenceAttestation: Equatable, Hashable { - public static func ==(lhs: RhiEvidenceAttestation, rhs: RhiEvidenceAttestation) -> Bool { - if lhs.issuerPubkey != rhs.issuerPubkey { - return false - } - if lhs.tradeId != rhs.tradeId { - return false - } - if lhs.claimMutationId != rhs.claimMutationId { - return false - } - if lhs.outcome != rhs.outcome { - return false - } - if lhs.observedAtUnixS != rhs.observedAtUnixS { - return false - } - if lhs.tradeGeneration != rhs.tradeGeneration { - return false - } - if lhs.statementDigest != rhs.statementDigest { - return false - } - if lhs.supersession != rhs.supersession { - return false - } - if lhs.canonicalContent != rhs.canonicalContent { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(issuerPubkey) - hasher.combine(tradeId) - hasher.combine(claimMutationId) - hasher.combine(outcome) - hasher.combine(observedAtUnixS) - hasher.combine(tradeGeneration) - hasher.combine(statementDigest) - hasher.combine(supersession) - hasher.combine(canonicalContent) - } } - +#if compiler(>=6) +extension RhiEvidenceAttestation: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -942,7 +938,7 @@ public func FfiConverterTypeRhiEvidenceAttestation_lower(_ value: RhiEvidenceAtt /** * Bounded projection of one canonical RHI evidence report. */ -public struct RhiEvidenceReport { +public struct RhiEvidenceReport: Equatable, Hashable { public var contractId: String public var contractVersion: UInt16 public var issuerPubkey: String @@ -978,83 +974,15 @@ public struct RhiEvidenceReport { self.supersession = supersession self.canonicalContent = canonicalContent } -} -#if compiler(>=6) -extension RhiEvidenceReport: Sendable {} -#endif -extension RhiEvidenceReport: Equatable, Hashable { - public static func ==(lhs: RhiEvidenceReport, rhs: RhiEvidenceReport) -> Bool { - if lhs.contractId != rhs.contractId { - return false - } - if lhs.contractVersion != rhs.contractVersion { - return false - } - if lhs.issuerPubkey != rhs.issuerPubkey { - return false - } - if lhs.tradeId != rhs.tradeId { - return false - } - if lhs.claimMutationId != rhs.claimMutationId { - return false - } - if lhs.outcome != rhs.outcome { - return false - } - if lhs.reasonCodes != rhs.reasonCodes { - return false - } - if lhs.projectionDigest != rhs.projectionDigest { - return false - } - if lhs.evidenceManifestDigest != rhs.evidenceManifestDigest { - return false - } - if lhs.evidencePolicyDigest != rhs.evidencePolicyDigest { - return false - } - if lhs.observedAtUnixS != rhs.observedAtUnixS { - return false - } - if lhs.tradeGeneration != rhs.tradeGeneration { - return false - } - if lhs.statementDigest != rhs.statementDigest { - return false - } - if lhs.supersession != rhs.supersession { - return false - } - if lhs.canonicalContent != rhs.canonicalContent { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(contractId) - hasher.combine(contractVersion) - hasher.combine(issuerPubkey) - hasher.combine(tradeId) - hasher.combine(claimMutationId) - hasher.combine(outcome) - hasher.combine(reasonCodes) - hasher.combine(projectionDigest) - hasher.combine(evidenceManifestDigest) - hasher.combine(evidencePolicyDigest) - hasher.combine(observedAtUnixS) - hasher.combine(tradeGeneration) - hasher.combine(statementDigest) - hasher.combine(supersession) - hasher.combine(canonicalContent) - } } - +#if compiler(>=6) +extension RhiEvidenceReport: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1119,7 +1047,7 @@ public func FfiConverterTypeRhiEvidenceReport_lower(_ value: RhiEvidenceReport) /** * Exact immutable RHI supersession reference. */ -public struct RhiEvidenceSupersession { +public struct RhiEvidenceSupersession: Equatable, Hashable { public var reportId: String public var eventId: String @@ -1129,31 +1057,15 @@ public struct RhiEvidenceSupersession { self.reportId = reportId self.eventId = eventId } -} -#if compiler(>=6) -extension RhiEvidenceSupersession: Sendable {} -#endif -extension RhiEvidenceSupersession: Equatable, Hashable { - public static func ==(lhs: RhiEvidenceSupersession, rhs: RhiEvidenceSupersession) -> Bool { - if lhs.reportId != rhs.reportId { - return false - } - if lhs.eventId != rhs.eventId { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(reportId) - hasher.combine(eventId) - } } - +#if compiler(>=6) +extension RhiEvidenceSupersession: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1192,7 +1104,7 @@ public func FfiConverterTypeRhiEvidenceSupersession_lower(_ value: RhiEvidenceSu /** * Signed NIP-01 event input for verified attestation admission. */ -public struct SignedEvent { +public struct SignedEvent: Equatable, Hashable { public var id: String public var authorPubkey: String public var createdAtUnixS: UInt64 @@ -1212,51 +1124,15 @@ public struct SignedEvent { self.content = content self.signature = signature } -} -#if compiler(>=6) -extension SignedEvent: Sendable {} -#endif -extension SignedEvent: Equatable, Hashable { - public static func ==(lhs: SignedEvent, rhs: SignedEvent) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.authorPubkey != rhs.authorPubkey { - return false - } - if lhs.createdAtUnixS != rhs.createdAtUnixS { - return false - } - if lhs.kind != rhs.kind { - return false - } - if lhs.tags != rhs.tags { - return false - } - if lhs.content != rhs.content { - return false - } - if lhs.signature != rhs.signature { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(authorPubkey) - hasher.combine(createdAtUnixS) - hasher.combine(kind) - hasher.combine(tags) - hasher.combine(content) - hasher.combine(signature) - } } - +#if compiler(>=6) +extension SignedEvent: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1305,7 +1181,7 @@ public func FfiConverterTypeSignedEvent_lower(_ value: SignedEvent) -> RustBuffe /** * Bounded projection of one canonical evidence manifest. */ -public struct TradeEvidenceManifest { +public struct TradeEvidenceManifest: Equatable, Hashable { public var contractId: String public var contractVersion: UInt16 public var tradeId: String @@ -1329,59 +1205,15 @@ public struct TradeEvidenceManifest { self.manifestDigest = manifestDigest self.canonicalBytesHex = canonicalBytesHex } -} -#if compiler(>=6) -extension TradeEvidenceManifest: Sendable {} -#endif -extension TradeEvidenceManifest: Equatable, Hashable { - public static func ==(lhs: TradeEvidenceManifest, rhs: TradeEvidenceManifest) -> Bool { - if lhs.contractId != rhs.contractId { - return false - } - if lhs.contractVersion != rhs.contractVersion { - return false - } - if lhs.tradeId != rhs.tradeId { - return false - } - if lhs.tradeGeneration != rhs.tradeGeneration { - return false - } - if lhs.observedAtUnixS != rhs.observedAtUnixS { - return false - } - if lhs.coverage != rhs.coverage { - return false - } - if lhs.evidencePolicyDigest != rhs.evidencePolicyDigest { - return false - } - if lhs.manifestDigest != rhs.manifestDigest { - return false - } - if lhs.canonicalBytesHex != rhs.canonicalBytesHex { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(contractId) - hasher.combine(contractVersion) - hasher.combine(tradeId) - hasher.combine(tradeGeneration) - hasher.combine(observedAtUnixS) - hasher.combine(coverage) - hasher.combine(evidencePolicyDigest) - hasher.combine(manifestDigest) - hasher.combine(canonicalBytesHex) - } } - +#if compiler(>=6) +extension TradeEvidenceManifest: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1434,7 +1266,7 @@ public func FfiConverterTypeTradeEvidenceManifest_lower(_ value: TradeEvidenceMa /** * One unsigned typed event plan ready for host-owned signing. */ -public struct TypedEvidenceEventPlan { +public struct TypedEvidenceEventPlan: Equatable, Hashable { public var contractId: String public var kind: UInt32 public var authorPubkey: String @@ -1454,51 +1286,15 @@ public struct TypedEvidenceEventPlan { self.tags = tags self.content = content } -} -#if compiler(>=6) -extension TypedEvidenceEventPlan: Sendable {} -#endif -extension TypedEvidenceEventPlan: Equatable, Hashable { - public static func ==(lhs: TypedEvidenceEventPlan, rhs: TypedEvidenceEventPlan) -> Bool { - if lhs.contractId != rhs.contractId { - return false - } - if lhs.kind != rhs.kind { - return false - } - if lhs.authorPubkey != rhs.authorPubkey { - return false - } - if lhs.createdAtUnixS != rhs.createdAtUnixS { - return false - } - if lhs.expectedEventId != rhs.expectedEventId { - return false - } - if lhs.tags != rhs.tags { - return false - } - if lhs.content != rhs.content { - return false - } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(contractId) - hasher.combine(kind) - hasher.combine(authorPubkey) - hasher.combine(createdAtUnixS) - hasher.combine(expectedEventId) - hasher.combine(tags) - hasher.combine(content) - } } - +#if compiler(>=6) +extension TypedEvidenceEventPlan: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1543,21 +1339,24 @@ public func FfiConverterTypeTypedEvidenceEventPlan_lower(_ value: TypedEvidenceE return FfiConverterTypeTypedEvidenceEventPlan.lower(value) } -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + /** * Current side-effect-free capability availability. */ -public enum CapabilityAvailability { +public enum CapabilityAvailability: Equatable, Hashable { case available case degraded case unavailable case unsupported -} + + + +} + #if compiler(>=6) extension CapabilityAvailability: Sendable {} #endif @@ -1623,27 +1422,23 @@ public func FfiConverterTypeCapabilityAvailability_lower(_ value: CapabilityAvai } -extension CapabilityAvailability: Equatable, Hashable {} - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** * Stable capability maturity independent of runtime availability. */ -public enum CapabilityMaturity { +public enum CapabilityMaturity: Equatable, Hashable { case stable case preview case experimental -} + + + +} + #if compiler(>=6) extension CapabilityMaturity: Sendable {} #endif @@ -1703,25 +1498,32 @@ public func FfiConverterTypeCapabilityMaturity_lower(_ value: CapabilityMaturity } -extension CapabilityMaturity: Equatable, Hashable {} + +/** + * Secret-safe SDK failure at the language boundary. + */ +public +enum Error: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { + case Sdk(code: String, message: String, retryable: Bool + ) -/** - * Secret-safe SDK failure at the language boundary. - */ -public enum Error: Swift.Error { + public var errorDescription: String? { + String(reflecting: self) + } - case Sdk(code: String, message: String, retryable: Bool - ) } +#if compiler(>=6) +extension Error: Sendable {} +#endif #if swift(>=5.8) @_documentation(visibility: private) @@ -1779,35 +1581,23 @@ public func FfiConverterTypeError_lower(_ value: Error) -> RustBuffer { } -extension Error: Equatable, Hashable {} - - - - -extension Error: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** * Final evidence coverage vocabulary. */ -public enum TradeEvidenceCoverage { +public enum TradeEvidenceCoverage: Equatable, Hashable { case missing case partial case scopeSatisfied case unsupported -} + + + +} + #if compiler(>=6) extension TradeEvidenceCoverage: Sendable {} #endif @@ -1873,27 +1663,23 @@ public func FfiConverterTypeTradeEvidenceCoverage_lower(_ value: TradeEvidenceCo } -extension TradeEvidenceCoverage: Equatable, Hashable {} - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** * Final evidence outcome vocabulary. */ -public enum TradeEvidenceOutcome { +public enum TradeEvidenceOutcome: Equatable, Hashable { case valid case invalid case indeterminate -} + + + +} + #if compiler(>=6) extension TradeEvidenceOutcome: Sendable {} #endif @@ -1953,13 +1739,6 @@ public func FfiConverterTypeTradeEvidenceOutcome_lower(_ value: TradeEvidenceOut } -extension TradeEvidenceOutcome: Equatable, Hashable {} - - - - - - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -2059,40 +1838,66 @@ fileprivate struct FfiConverterSequenceSequenceString: FfiConverterRustBuffer { } } private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0 -private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1 +private let UNIFFI_RUST_FUTURE_POLL_WAKE: Int8 = 1 fileprivate let uniffiContinuationHandleMap = UniffiHandleMap<UnsafeContinuation<Int8, Never>>() +// radroots-swift-cancellation-v1. Only the observing Rust future is cancelled; +// admitted work and obtained material remain owned by the shared runtime. +// NSLock serializes cancel against release. The unchecked Sendable owner has +// no unsynchronized mutable state; its immutable C callback is Sendable. +fileprivate final class UniffiRustCancellation: @unchecked Sendable { + private let lock = NSLock() + private var handle: UInt64? + private let cancelFunction: @Sendable (UInt64) -> Void + init(_ handle: UInt64, _ cancelFunction: @escaping @Sendable (UInt64) -> Void) { + self.handle = handle + self.cancelFunction = cancelFunction + } + func cancel() { + lock.lock() + defer { lock.unlock() } + if let handle { cancelFunction(handle) } + } + func finish() { + lock.lock() + defer { lock.unlock() } + handle = nil + } +} + fileprivate func uniffiRustCallAsync<F, T>( rustFutureFunc: () -> UInt64, pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (), completeFunc: (UInt64, UnsafeMutablePointer<RustCallStatus>) -> F, + cancelFunc: @escaping @Sendable (UInt64) -> Void, freeFunc: (UInt64) -> (), liftFunc: (F) throws -> T, errorHandler: ((RustBuffer) throws -> Swift.Error)? ) async throws -> T { - // Make sure to call the ensure init function since future creation doesn't have a - // RustCallStatus param, so doesn't use makeRustCall() + try Task.checkCancellation() uniffiEnsureRadrootsSdkFfiInitialized() - let rustFuture = rustFutureFunc() + let handle = rustFutureFunc() + let cancellation = UniffiRustCancellation(handle, cancelFunc) defer { - freeFunc(rustFuture) - } - var pollResult: Int8; - repeat { - pollResult = await withUnsafeContinuation { - pollFunc( - rustFuture, - uniffiFutureContinuationCallback, - uniffiContinuationHandleMap.insert(obj: $0) - ) - } - } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY - - return try liftFunc(makeRustCall( - { completeFunc(rustFuture, $0) }, - errorHandler: errorHandler - )) + cancellation.finish() + freeFunc(handle) + } + return try await withTaskCancellationHandler { + var ready: Int8 + repeat { + ready = await withUnsafeContinuation { continuation in + let callbackHandle = uniffiContinuationHandleMap.insert(obj: continuation) + pollFunc(handle, { callbackHandle, status in + uniffiFutureContinuationCallback(handle: callbackHandle, pollResult: status) + }, callbackHandle) + } + } while ready != UNIFFI_RUST_FUTURE_POLL_READY + let result = try makeRustCall({ completeFunc(handle, $0) }, errorHandler: errorHandler) + return try liftFunc(result) + } onCancel: { + cancellation.cancel() + } } // Callback handlers for an async calls. These are invoked by Rust when the future is ready. They @@ -2106,30 +1911,34 @@ fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: In } public func parseRhiEvidenceReport(canonicalContent: String)throws -> RhiEvidenceReport { return try FfiConverterTypeRhiEvidenceReport_lift(try rustCallWithError(FfiConverterTypeError_lift) { + uniffiCallStatus in uniffi_radroots_sdk_ffi_fn_func_parse_rhi_evidence_report( - FfiConverterString.lower(canonicalContent),$0 + FfiConverterString.lower(canonicalContent),uniffiCallStatus ) }) } public func parseTradeEvidenceManifest(canonicalBytes: Data)throws -> TradeEvidenceManifest { return try FfiConverterTypeTradeEvidenceManifest_lift(try rustCallWithError(FfiConverterTypeError_lift) { + uniffiCallStatus in uniffi_radroots_sdk_ffi_fn_func_parse_trade_evidence_manifest( - FfiConverterData.lower(canonicalBytes),$0 + FfiConverterData.lower(canonicalBytes),uniffiCallStatus ) }) } public func prepareRhiEvidenceAttestation(canonicalContent: String, createdAtUnixS: UInt64)throws -> TypedEvidenceEventPlan { return try FfiConverterTypeTypedEvidenceEventPlan_lift(try rustCallWithError(FfiConverterTypeError_lift) { + uniffiCallStatus in uniffi_radroots_sdk_ffi_fn_func_prepare_rhi_evidence_attestation( FfiConverterString.lower(canonicalContent), - FfiConverterUInt64.lower(createdAtUnixS),$0 + FfiConverterUInt64.lower(createdAtUnixS),uniffiCallStatus ) }) } public func validateRhiEvidenceAttestation(event: SignedEvent)throws -> RhiEvidenceAttestation { return try FfiConverterTypeRhiEvidenceAttestation_lift(try rustCallWithError(FfiConverterTypeError_lift) { + uniffiCallStatus in uniffi_radroots_sdk_ffi_fn_func_validate_rhi_evidence_attestation( - FfiConverterTypeSignedEvent_lower(event),$0 + FfiConverterTypeSignedEvent_lower(event),uniffiCallStatus ) }) } @@ -2143,34 +1952,34 @@ private enum InitializationResult { // the code inside is only computed once. private let initializationResult: InitializationResult = { // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 29 + let bindings_contract_version = 30 // Get the scaffolding contract version by calling the into the dylib let scaffolding_contract_version = ffi_radroots_sdk_ffi_uniffi_contract_version() if bindings_contract_version != scaffolding_contract_version { return InitializationResult.contractVersionMismatch } - if (uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report() != 37549) { + if (uniffi_radroots_sdk_ffi_checksum_func_parse_rhi_evidence_report() != 10431) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest() != 35922) { + if (uniffi_radroots_sdk_ffi_checksum_func_parse_trade_evidence_manifest() != 17039) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation() != 53127) { + if (uniffi_radroots_sdk_ffi_checksum_func_prepare_rhi_evidence_attestation() != 35556) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation() != 46555) { + if (uniffi_radroots_sdk_ffi_checksum_func_validate_rhi_evidence_attestation() != 64772) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities() != 23938) { + if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_capabilities() != 35060) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close() != 15210) { + if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_close() != 34026) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed() != 40205) { + if (uniffi_radroots_sdk_ffi_checksum_method_mobileclient_is_closed() != 56426) { return InitializationResult.apiChecksumMismatch } - if (uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory() != 50243) { + if (uniffi_radroots_sdk_ffi_checksum_constructor_mobileclient_memory() != 5837) { return InitializationResult.apiChecksumMismatch } diff --git a/generated/swift/radroots_sdkFFI.h b/generated/swift/radroots_sdkFFI.h @@ -50,9 +50,9 @@ typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_FREE -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_FREE -typedef void (*UniffiForeignFutureFree)(uint64_t +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t ); #endif @@ -62,224 +62,216 @@ typedef void (*UniffiCallbackInterfaceFree)(uint64_t ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE -#define UNIFFI_FFIDEF_FOREIGN_FUTURE -typedef struct UniffiForeignFuture { +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +typedef uint64_t (*UniffiCallbackInterfaceClone)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +typedef struct UniffiForeignFutureDroppedCallbackStruct { uint64_t handle; - UniffiForeignFutureFree _Nonnull free; -} UniffiForeignFuture; + UniffiForeignFutureDroppedCallback _Nonnull free; +} UniffiForeignFutureDroppedCallbackStruct; #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U8 -typedef struct UniffiForeignFutureStructU8 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +typedef struct UniffiForeignFutureResultU8 { uint8_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructU8; +} UniffiForeignFutureResultU8; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureStructU8 +typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I8 -typedef struct UniffiForeignFutureStructI8 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +typedef struct UniffiForeignFutureResultI8 { int8_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructI8; +} UniffiForeignFutureResultI8; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureStructI8 +typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U16 -typedef struct UniffiForeignFutureStructU16 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +typedef struct UniffiForeignFutureResultU16 { uint16_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructU16; +} UniffiForeignFutureResultU16; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureStructU16 +typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I16 -typedef struct UniffiForeignFutureStructI16 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +typedef struct UniffiForeignFutureResultI16 { int16_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructI16; +} UniffiForeignFutureResultI16; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureStructI16 +typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U32 -typedef struct UniffiForeignFutureStructU32 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +typedef struct UniffiForeignFutureResultU32 { uint32_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructU32; +} UniffiForeignFutureResultU32; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureStructU32 +typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I32 -typedef struct UniffiForeignFutureStructI32 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +typedef struct UniffiForeignFutureResultI32 { int32_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructI32; +} UniffiForeignFutureResultI32; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureStructI32 +typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_U64 -typedef struct UniffiForeignFutureStructU64 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +typedef struct UniffiForeignFutureResultU64 { uint64_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructU64; +} UniffiForeignFutureResultU64; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureStructU64 +typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_I64 -typedef struct UniffiForeignFutureStructI64 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +typedef struct UniffiForeignFutureResultI64 { int64_t returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructI64; +} UniffiForeignFutureResultI64; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureStructI64 +typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F32 -typedef struct UniffiForeignFutureStructF32 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +typedef struct UniffiForeignFutureResultF32 { float returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructF32; +} UniffiForeignFutureResultF32; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureStructF32 +typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_F64 -typedef struct UniffiForeignFutureStructF64 { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +typedef struct UniffiForeignFutureResultF64 { double returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructF64; +} UniffiForeignFutureResultF64; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureStructF64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_POINTER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_POINTER -typedef struct UniffiForeignFutureStructPointer { - void*_Nonnull returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureStructPointer; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_POINTER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_POINTER -typedef void (*UniffiForeignFutureCompletePointer)(uint64_t, UniffiForeignFutureStructPointer +typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_RUST_BUFFER -typedef struct UniffiForeignFutureStructRustBuffer { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +typedef struct UniffiForeignFutureResultRustBuffer { RustBuffer returnValue; RustCallStatus callStatus; -} UniffiForeignFutureStructRustBuffer; +} UniffiForeignFutureResultRustBuffer; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureStructRustBuffer +typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer ); #endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_STRUCT_VOID -typedef struct UniffiForeignFutureStructVoid { +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +typedef struct UniffiForeignFutureResultVoid { RustCallStatus callStatus; -} UniffiForeignFutureStructVoid; +} UniffiForeignFutureResultVoid; #endif #ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID #define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid +typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_CLONE_MOBILECLIENT #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_CLONE_MOBILECLIENT -void*_Nonnull uniffi_radroots_sdk_ffi_fn_clone_mobileclient(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +uint64_t uniffi_radroots_sdk_ffi_fn_clone_mobileclient(uint64_t handle, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_FREE_MOBILECLIENT #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_FREE_MOBILECLIENT -void uniffi_radroots_sdk_ffi_fn_free_mobileclient(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +void uniffi_radroots_sdk_ffi_fn_free_mobileclient(uint64_t handle, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_CONSTRUCTOR_MOBILECLIENT_MEMORY #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_CONSTRUCTOR_MOBILECLIENT_MEMORY -void*_Nonnull uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(RustCallStatus *_Nonnull out_status +uint64_t uniffi_radroots_sdk_ffi_fn_constructor_mobileclient_memory(RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_CAPABILITIES #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_CAPABILITIES -RustBuffer uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +RustBuffer uniffi_radroots_sdk_ffi_fn_method_mobileclient_capabilities(uint64_t ptr, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_CLOSE #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_CLOSE -uint64_t uniffi_radroots_sdk_ffi_fn_method_mobileclient_close(void*_Nonnull ptr +uint64_t uniffi_radroots_sdk_ffi_fn_method_mobileclient_close(uint64_t ptr ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_IS_CLOSED #define UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_METHOD_MOBILECLIENT_IS_CLOSED -int8_t uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +int8_t uniffi_radroots_sdk_ffi_fn_method_mobileclient_is_closed(uint64_t ptr, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_RADROOTS_SDK_FFI_FN_FUNC_PARSE_RHI_EVIDENCE_REPORT @@ -522,26 +514,6 @@ void ffi_radroots_sdk_ffi_rust_future_free_f64(uint64_t handle double ffi_radroots_sdk_ffi_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status ); #endif -#ifndef UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_POLL_POINTER -#define UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_POLL_POINTER -void ffi_radroots_sdk_ffi_rust_future_poll_pointer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_CANCEL_POINTER -#define UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_CANCEL_POINTER -void ffi_radroots_sdk_ffi_rust_future_cancel_pointer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_FREE_POINTER -#define UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_FREE_POINTER -void ffi_radroots_sdk_ffi_rust_future_free_pointer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_COMPLETE_POINTER -#define UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_COMPLETE_POINTER -void*_Nonnull ffi_radroots_sdk_ffi_rust_future_complete_pointer(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif #ifndef UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_POLL_RUST_BUFFER #define UNIFFI_FFIDEF_FFI_RADROOTS_SDK_FFI_RUST_FUTURE_POLL_RUST_BUFFER void ffi_radroots_sdk_ffi_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data diff --git a/generated/swift/source.lock b/generated/swift/source.lock @@ -2,13 +2,13 @@ "schema_version": 1, "source_package": "radroots_sdk_ffi", "source_version": "0.1.0-alpha", - "source_sha256": "d8b1391c6f58ef35d9abefb005b6adabf3b424fadc3a615180a9df75fb55b0b5", - "generator": "uniffi", - "generator_version": "0.29.5", + "source_sha256": "ff679e85748e0872694dac745522801997d192774f77238ec050379027d1fb70", + "generator": "radroots_ffi_bindgen", + "generator_version": "0.32.2+radroots-native-v2", "language": "swift", "outputs": { - "radroots_sdk.swift": "38ff1a652ff49b45c48601d2b1c0064103c1e815df9e80604f3369af2e53f4ac", - "radroots_sdkFFI.h": "2efe02ecda4a68a495bacc61acf8ff41dc84bc01d9132a00b38353a57c51466a", + "radroots_sdk.swift": "232932067903afb88fdb6f30714a35ef688b691da23b12ff98c07afdba3a3109", + "radroots_sdkFFI.h": "03601cc25edbd4d3098460c828a55009b788cbf787864983f974db22db1e47e0", "radroots_sdkFFI.modulemap": "b18fa5af1567a940fc699afe371a3a4653dca206f3233bcdf322062ab8192170" } } diff --git a/radroots.lib.source-lock.v1.toml b/radroots.lib.source-lock.v1.toml @@ -1,8 +1,8 @@ schema = "radroots.lib.source-lock.v1" repository = "https://github.com/radrootslabs/lib" -revision = "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4" +revision = "3d9f666bf9e9f66d1ade4293c516f03c88caf35a" architecture = "radroots.crates.release.v2" -workspace_catalog_sha256 = "1e679431ad70a024affc52e6c71151459aca41707429dd8015d014d27e5f40b6" +workspace_catalog_sha256 = "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8" version = "0.1.0-alpha" -source_archive_sha256 = "3b27bbb1cacd5329b9c7f2f7f7bf8c826e6f06625ad8f6520f6e5e8e4278b54a" -lockfile_sha256 = "c46a2552ecc6632625064333edb96aff26fe8b3560fa7e293c1aa25fda326db1" +source_archive_sha256 = "b38794a617927c6f891af234dc8ef6f43ac25b47df39f48f0588ddfa674c643a" +lockfile_sha256 = "273129eb54f7c1f2da2ecbcdb874c862bf6966f98bd21de30b9bc0a8cd3375fd" diff --git a/tools/radroots_sdk_package_license.test.mjs b/tools/radroots_sdk_package_license.test.mjs @@ -8,7 +8,7 @@ import test from "node:test"; import { validateGeneratedPackageLicenses } from "./radroots_sdk_package_license_lib.mjs"; const sourceRoot = fileURLToPath(new URL("..", import.meta.url)); -const revision = "b6f927c4d484ed2f8afcf171a83f2c8f967fb4d4"; +const revision = "3d9f666bf9e9f66d1ade4293c516f03c88caf35a"; function fixture() { const root = mkdtempSync(join(tmpdir(), "radroots-sdk-licenses-"));