From e94e7872e734198e734ddba93a38b63e0ad2c716 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 08:54:40 +0000 Subject: [PATCH 1/7] chore: untrack generated Rust and iOS outputs --- .gitignore | 11 + .../TrUAPIHost/Resources/truapi-container.js | 152 - .../Sources/TrUAPIHost/truapi.swift | 7291 ----------------- .../Sources/TrUAPIHost/truapi_platform.swift | 2631 ------ .../Sources/TrUAPIHost/truapi_server.swift | 6084 -------------- .../truapiFFI/include/module.modulemap | 7 - .../Sources/truapiFFI/include/truapiFFI.h | 512 -- .../include/module.modulemap | 7 - .../include/truapi_platformFFI.h | 512 -- .../truapi_serverFFI/include/module.modulemap | 7 - .../include/truapi_serverFFI.h | 1500 ---- .../TrUAPIProvider/truapi_provider.swift | 1373 ---- .../include/module.modulemap | 7 - .../include/truapi_providerFFI.h | 638 -- .../truapi-server/src/generated/dispatcher.rs | 2736 ------- .../crates/truapi-server/src/generated/mod.rs | 4 - .../truapi-server/src/generated/wire_table.rs | 804 -- .../src/wasm/generated_bridge.rs | 470 -- 18 files changed, 11 insertions(+), 24735 deletions(-) delete mode 100644 ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js delete mode 100644 ios/truapi-host/Sources/TrUAPIHost/truapi.swift delete mode 100644 ios/truapi-host/Sources/TrUAPIHost/truapi_platform.swift delete mode 100644 ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift delete mode 100644 ios/truapi-host/Sources/truapiFFI/include/module.modulemap delete mode 100644 ios/truapi-host/Sources/truapiFFI/include/truapiFFI.h delete mode 100644 ios/truapi-host/Sources/truapi_platformFFI/include/module.modulemap delete mode 100644 ios/truapi-host/Sources/truapi_platformFFI/include/truapi_platformFFI.h delete mode 100644 ios/truapi-host/Sources/truapi_serverFFI/include/module.modulemap delete mode 100644 ios/truapi-host/Sources/truapi_serverFFI/include/truapi_serverFFI.h delete mode 100644 ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift delete mode 100644 ios/truapi-provider/Sources/truapi_providerFFI/include/module.modulemap delete mode 100644 ios/truapi-provider/Sources/truapi_providerFFI/include/truapi_providerFFI.h delete mode 100644 rust/crates/truapi-server/src/generated/dispatcher.rs delete mode 100644 rust/crates/truapi-server/src/generated/mod.rs delete mode 100644 rust/crates/truapi-server/src/generated/wire_table.rs delete mode 100644 rust/crates/truapi-server/src/wasm/generated_bridge.rs diff --git a/.gitignore b/.gitignore index 34260c5fb..0ab19db1f 100644 --- a/.gitignore +++ b/.gitignore @@ -61,8 +61,19 @@ android/truapi-host/src/main/kotlin/generated/ android/truapi-host/src/main/jniLibs/ android/truapi-provider/src/main/kotlin/generated/ android/truapi-provider/src/main/jniLibs/ +# UniFFI Swift bindings and the bundled container script +ios/truapi-host/Sources/TrUAPIHost/truapi*.swift +ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js +ios/truapi-host/Sources/truapiFFI/ +ios/truapi-host/Sources/truapi_platformFFI/ +ios/truapi-host/Sources/truapi_serverFFI/ +ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift +ios/truapi-provider/Sources/truapi_providerFFI/ ios/truapi-provider/Binaries/ rust/crates/truapi-server/pkg/ +# truapi-codegen Rust outputs +rust/crates/truapi-server/src/generated/ +rust/crates/truapi-server/src/wasm/generated_bridge.rs js/packages/truapi/src/generated/ js/packages/truapi/dist/generated/ js/packages/truapi-host/src/generated/ diff --git a/ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js b/ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js deleted file mode 100644 index f1d2714e5..000000000 --- a/ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js +++ /dev/null @@ -1,152 +0,0 @@ -"use strict"; -(() => { - // src/freeze.ts - var failures = []; - function describe(obj) { - if (obj === globalThis) return "window"; - const name = obj?.constructor?.name; - return typeof name === "string" && name.length > 0 ? name : "object"; - } - function recordFailure(obj, prop) { - failures.push(`${describe(obj)}.${prop}`); - } - function freezeAndDelete(obj, prop) { - try { - Object.defineProperty(obj, prop, { - get: () => void 0, - set() { - }, - configurable: false - }); - } catch { - try { - delete obj[prop]; - } catch { - } - } - if (obj?.[prop] !== void 0) { - recordFailure(obj, prop); - } - } - function freezeValue(obj, prop, value) { - try { - Object.defineProperty(obj, prop, { - get: () => value, - set() { - }, - configurable: false - }); - } catch { - } - if (obj?.[prop] !== value) { - recordFailure(obj, prop); - } - } - function freezeCustom(obj, prop, descriptor, verify) { - try { - Object.defineProperty(obj, prop, { configurable: false, ...descriptor }); - } catch { - } - let locked = false; - try { - locked = verify(obj?.[prop]); - } catch { - } - if (!locked) { - recordFailure(obj, prop); - } - } - function reportLockdownFailures() { - if (failures.length === 0) { - return; - } - const message = `TrUAPI container lockdown failed for: ${failures.join(", ")}`; - try { - console.error(message); - } catch { - } - throw new Error(message); - } - - // src/webrtc.ts - var POLICY_GLOBAL = "__truapi_policy__"; - function installWebRtcPolicy(win, allowed) { - if (allowed === true) { - return; - } - freezeAndDelete(win, "RTCPeerConnection"); - freezeAndDelete(win, "webkitRTCPeerConnection"); - freezeAndDelete(win, "mozRTCPeerConnection"); - } - function consumeWebRtcPolicy(win) { - const allowed = win?.[POLICY_GLOBAL]?.webRtcAllowed; - freezeAndDelete(win, POLICY_GLOBAL); - return allowed; - } - - // src/index.ts - var _nativeFetch = window.fetch.bind(window); - var _NativeWebSocket = window.WebSocket; - var _bridgeUrl = window.__truapi_localhost?.url; - var _GatedWebSocket = new Proxy(window.WebSocket, { - construct(target, args) { - if (_bridgeUrl !== void 0 && args[0] === _bridgeUrl) { - return new _NativeWebSocket(args[0]); - } - throw new TypeError("Network access is not allowed"); - } - }); - freezeValue(window, "WebSocket", _GatedWebSocket); - freezeCustom( - _NativeWebSocket.prototype, - "constructor", - { value: _GatedWebSocket, writable: false }, - (current) => current === _GatedWebSocket - ); - freezeValue(window, "fetch", (input, init) => { - try { - const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; - const url = new URL(raw, window.location.href); - if (url.origin === window.location.origin) { - return _nativeFetch(input, init); - } - } catch { - } - return Promise.reject(new TypeError("Network access is not allowed")); - }); - freezeAndDelete(window, "XMLHttpRequest"); - freezeAndDelete(window, "EventSource"); - freezeValue(navigator, "sendBeacon", () => false); - freezeAndDelete(window, "indexedDB"); - freezeAndDelete(window, "caches"); - freezeCustom( - document, - "cookie", - { get: () => "", set: () => { - } }, - (current) => current === "" - ); - freezeAndDelete(window, "SharedWorker"); - if (navigator.serviceWorker) { - const _stubServiceWorker = Object.freeze({ - register: () => { - throw new Error("ServiceWorker is not available"); - } - }); - freezeCustom( - navigator, - "serviceWorker", - { value: _stubServiceWorker, writable: false }, - (current) => current === _stubServiceWorker - ); - } - var _createElement = document.createElement.bind(document); - freezeValue(document, "createElement", (tagName, options) => { - if (tagName.toLowerCase() === "iframe") { - throw new Error("iframe creation is not allowed"); - } - return _createElement(tagName, options); - }); - installWebRtcPolicy(window, consumeWebRtcPolicy(window)); - reportLockdownFailures(); -})(); diff --git a/ios/truapi-host/Sources/TrUAPIHost/truapi.swift b/ios/truapi-host/Sources/TrUAPIHost/truapi.swift deleted file mode 100644 index 899bb6904..000000000 --- a/ios/truapi-host/Sources/TrUAPIHost/truapi.swift +++ /dev/null @@ -1,7291 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -// swiftlint:disable all -import Foundation - -// Depending on the consumer's build setup, the low-level FFI code -// might be in a separate module, or it might be compiled inline into -// this module. This is a bit of light hackery to work with both. -#if canImport(truapiFFI) -import truapiFFI -#endif - -fileprivate extension RustBuffer { - // Allocate a new buffer, copying the contents of a `UInt8` array. - init(bytes: [UInt8]) { - let rbuf = bytes.withUnsafeBufferPointer { ptr in - RustBuffer.from(ptr) - } - self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) - } - - static func empty() -> RustBuffer { - RustBuffer(capacity: 0, len:0, data: nil) - } - - static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_truapi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } - } - - // Frees the buffer in place. - // The buffer must not be used after this is called. - func deallocate() { - try! rustCall { ffi_truapi_rustbuffer_free(self, $0) } - } -} - -fileprivate extension ForeignBytes { - init(bufferPointer: UnsafeBufferPointer) { - 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(_ 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 -// lifting and lowering that type from C-compatible data, and for reading and writing -// values of that type in a buffer. - -// Helper classes/extensions that don't change. -// Someday, this will be in a library of its own. - -fileprivate extension Data { - init(rustBuffer: RustBuffer) { - self.init( - bytesNoCopy: rustBuffer.data!, - count: Int(rustBuffer.len), - deallocator: .none - ) - } -} - -// Define reader functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. -// -// With external types, one swift source file needs to be able to call the read -// method on another source file's FfiConverter, but then what visibility -// should Reader have? -// - If Reader is fileprivate, then this means the read() must also -// be fileprivate, which doesn't work with external types. -// - If Reader is internal/public, we'll get compile errors since both source -// files will try define the same type. -// -// Instead, the read() method and these helper functions input a tuple of data - -fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { - (data: data, offset: 0) -} - -// Reads an integer at the current offset, in big-endian order, and advances -// the offset on success. Throws if reading the integer would move the -// offset past the end of the buffer. -fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset...size - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - if T.self == UInt8.self { - let value = reader.data[reader.offset] - reader.offset += 1 - return value as! T - } - var value: T = 0 - let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) - reader.offset = range.upperBound - return value.bigEndian -} - -// Reads an arbitrary number of bytes, to be used to read -// raw bytes, this is useful when lifting strings -fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { - let range = reader.offset..<(reader.offset+count) - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - var value = [UInt8](repeating: 0, count: count) - value.withUnsafeMutableBufferPointer({ buffer in - reader.data.copyBytes(to: buffer, from: range) - }) - reader.offset = range.upperBound - return value -} - -// Reads a float at the current offset. -fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return Float(bitPattern: try readInt(&reader)) -} - -// Reads a float at the current offset. -fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return Double(bitPattern: try readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { - return reader.offset < reader.data.count -} - -// Define writer functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. See the above discussion on Readers for details. - -fileprivate func createWriter() -> [UInt8] { - return [] -} - -fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { - writer.append(contentsOf: byteArr) -} - -// Writes an integer in big-endian order. -// -// Warning: make sure what you are trying to write -// is in the correct type! -fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous to the Rust trait of the same name. -fileprivate protocol FfiConverter { - associatedtype FfiType - associatedtype SwiftType - - static func lift(_ value: FfiType) throws -> SwiftType - static func lower(_ value: SwiftType) -> FfiType - static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType - static func write(_ value: SwiftType, into buf: inout [UInt8]) -} - -// Types conforming to `Primitive` pass themselves directly over the FFI. -fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } - -extension FfiConverterPrimitive { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> FfiType { - return value - } -} - -// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. -// Used for complex types where it's hard to write a custom lift/lower. -fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ buf: RustBuffer) throws -> SwiftType { - var reader = createReader(data: Data(rustBuffer: buf)) - let value = try read(from: &reader) - if hasRemaining(reader) { - throw UniffiInternalError.incompleteData - } - buf.deallocate() - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> RustBuffer { - var writer = createWriter() - write(value, into: &writer) - return RustBuffer(bytes: writer) - } -} -// An error type for FFI errors. These errors occur at the UniFFI level, not -// the library level. -fileprivate enum UniffiInternalError: LocalizedError { - case bufferOverflow - case incompleteData - case unexpectedOptionalTag - case unexpectedEnumCase - case unexpectedNullPointer - case unexpectedRustCallStatusCode - case unexpectedRustCallError - case unexpectedStaleHandle - case rustPanic(_ message: String) - - public var errorDescription: String? { - switch self { - case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" - case .incompleteData: return "The buffer still has data after lifting its containing value" - case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" - case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" - case .unexpectedNullPointer: return "Raw pointer value was null" - case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" - case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" - case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" - case let .rustPanic(message): return message - } - } -} - -fileprivate extension NSLock { - func withLock(f: () throws -> T) rethrows -> T { - self.lock() - defer { self.unlock() } - return try f() - } -} - -fileprivate let CALL_SUCCESS: Int8 = 0 -fileprivate let CALL_ERROR: Int8 = 1 -fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 -fileprivate let CALL_CANCELLED: Int8 = 3 - -fileprivate extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer.init( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - let neverThrow: ((RustBuffer) throws -> Never)? = nil - return try makeRustCall(callback, errorHandler: neverThrow) -} - -private func rustCallWithError( - _ errorHandler: @escaping (RustBuffer) throws -> E, - _ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: errorHandler) -} - -private func makeRustCall( - _ callback: (UnsafeMutablePointer) -> T, - errorHandler: ((RustBuffer) throws -> E)? -) throws -> T { - uniffiEnsureTruapiInitialized() - var callStatus = RustCallStatus.init() - let returnedVal = callback(&callStatus) - try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) - return returnedVal -} - -private func uniffiCheckCallStatus( - callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> E)? -) throws { - switch callStatus.code { - case CALL_SUCCESS: - return - - case CALL_ERROR: - if let errorHandler = errorHandler { - throw try errorHandler(callStatus.errorBuf) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.unexpectedRustCallError - } - - case CALL_UNEXPECTED_ERROR: - // When the rust code sees a panic, it tries to construct a RustBuffer - // with the message. But if that code panics, then it just sends back - // an empty buffer. - if callStatus.errorBuf.len > 0 { - throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - case CALL_CANCELLED: - fatalError("Cancellation not supported yet") - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -private func uniffiTraitInterfaceCall( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> () -) { - do { - try writeReturn(makeCall()) - } catch let error { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) - } -} - -private func uniffiTraitInterfaceCallWithError( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> (), - lowerError: (E) -> RustBuffer -) { - do { - try writeReturn(makeCall()) - } catch let error as E { - callStatus.pointee.code = CALL_ERROR - callStatus.pointee.errorBuf = lowerError(error) - } catch { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - 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: @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 = UNIFFI_HANDLEMAP_INITIAL - - func insert(obj: T) -> UInt64 { - lock.withLock { - 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 { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - 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 { - guard let obj = map.removeValue(forKey: handle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - var count: Int { - get { - map.count - } - } -} - - -// Public interface members begin here. - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt8: FfiConverterPrimitive { - typealias FfiType = UInt8 - typealias SwiftType = UInt8 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: UInt8, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { - typealias FfiType = UInt32 - typealias SwiftType = UInt32 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { - typealias FfiType = UInt64 - typealias SwiftType = UInt64 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterBool : FfiConverter { - typealias FfiType = Int8 - typealias SwiftType = Bool - - public static func lift(_ value: Int8) throws -> Bool { - return value != 0 - } - - public static func lower(_ value: Bool) -> Int8 { - return value ? 1 : 0 - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { - return try lift(readInt(&buf)) - } - - public static func write(_ value: Bool, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterString: FfiConverter { - typealias SwiftType = String - typealias FfiType = RustBuffer - - public static func lift(_ value: RustBuffer) throws -> String { - defer { - value.deallocate() - } - if value.data == nil { - return String() - } - let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) - // 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 { - return value.utf8CString.withUnsafeBufferPointer { ptr in - // The swift string gives us int8_t, we want uint8_t. - ptr.withMemoryRebound(to: UInt8.self) { ptr in - // The swift string gives us a trailing null byte, we don't want it. - let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) - return RustBuffer.from(buf) - } - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { - let len: Int32 = try readInt(&buf) - // 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]) { - let len = Int32(value.utf8.count) - writeInt(&buf, len) - writeBytes(&buf, value.utf8) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterData: FfiConverterRustBuffer { - typealias SwiftType = Data - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { - let len: Int32 = try readInt(&buf) - return Data(try readBytes(&buf, count: Int(len))) - } - - public static func write(_ value: Data, into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - writeBytes(&buf, value) - } -} - - -/** - * Payload when a user clicks an action button. - */ -public struct ActionTrigger: Equatable, Hashable { - /** - * Message containing the action, as returned by `Chat::post_message` in - * [`HostChatPostMessageResponse::message_id`]. - */ - public var messageId: String - /** - * Which action was triggered. - */ - public var actionId: String - /** - * Optional additional data. - */ - public var payload: Data? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Message containing the action, as returned by `Chat::post_message` in - * [`HostChatPostMessageResponse::message_id`]. - */messageId: String, - /** - * Which action was triggered. - */actionId: String, - /** - * Optional additional data. - */payload: Data?) { - self.messageId = messageId - self.actionId = actionId - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension ActionTrigger: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeActionTrigger: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionTrigger { - return - try ActionTrigger( - messageId: FfiConverterString.read(from: &buf), - actionId: FfiConverterString.read(from: &buf), - payload: FfiConverterOptionData.read(from: &buf) - ) - } - - public static func write(_ value: ActionTrigger, into buf: inout [UInt8]) { - FfiConverterString.write(value.messageId, into: &buf) - FfiConverterString.write(value.actionId, into: &buf) - FfiConverterOptionData.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActionTrigger_lift(_ buf: RustBuffer) throws -> ActionTrigger { - return try FfiConverterTypeActionTrigger.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActionTrigger_lower(_ value: ActionTrigger) -> RustBuffer { - return FfiConverterTypeActionTrigger.lower(value) -} - - -/** - * Background styling. - */ -public struct Background: Equatable, Hashable { - /** - * Background color. - */ - public var color: ColorToken - /** - * Background shape. - */ - public var shape: Shape? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Background color. - */color: ColorToken, - /** - * Background shape. - */shape: Shape?) { - self.color = color - self.shape = shape - } - - - - -} - -#if compiler(>=6) -extension Background: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeBackground: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Background { - return - try Background( - color: FfiConverterTypeColorToken.read(from: &buf), - shape: FfiConverterOptionTypeShape.read(from: &buf) - ) - } - - public static func write(_ value: Background, into buf: inout [UInt8]) { - FfiConverterTypeColorToken.write(value.color, into: &buf) - FfiConverterOptionTypeShape.write(value.shape, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBackground_lift(_ buf: RustBuffer) throws -> Background { - return try FfiConverterTypeBackground.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBackground_lower(_ value: Background) -> RustBuffer { - return FfiConverterTypeBackground.lower(value) -} - - -/** - * Border styling. - */ -public struct BorderStyle: Equatable, Hashable { - /** - * Border width. - */ - public var width: Size - /** - * Border color. - */ - public var color: ColorToken - /** - * Border shape. - */ - public var shape: Shape? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Border width. - */width: Size, - /** - * Border color. - */color: ColorToken, - /** - * Border shape. - */shape: Shape?) { - self.width = width - self.color = color - self.shape = shape - } - - - - -} - -#if compiler(>=6) -extension BorderStyle: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeBorderStyle: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BorderStyle { - return - try BorderStyle( - width: FfiConverterTypeSize.read(from: &buf), - color: FfiConverterTypeColorToken.read(from: &buf), - shape: FfiConverterOptionTypeShape.read(from: &buf) - ) - } - - public static func write(_ value: BorderStyle, into buf: inout [UInt8]) { - FfiConverterTypeSize.write(value.width, into: &buf) - FfiConverterTypeColorToken.write(value.color, into: &buf) - FfiConverterOptionTypeShape.write(value.shape, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBorderStyle_lift(_ buf: RustBuffer) throws -> BorderStyle { - return try FfiConverterTypeBorderStyle.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBorderStyle_lower(_ value: BorderStyle) -> RustBuffer { - return FfiConverterTypeBorderStyle.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::Box`] container. - */ -public struct BoxProps: Equatable, Hashable { - /** - * Content alignment within the box. - */ - public var contentAlignment: ContentAlignment? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Content alignment within the box. - */contentAlignment: ContentAlignment?) { - self.contentAlignment = contentAlignment - } - - - - -} - -#if compiler(>=6) -extension BoxProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeBoxProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoxProps { - return - try BoxProps( - contentAlignment: FfiConverterOptionTypeContentAlignment.read(from: &buf) - ) - } - - public static func write(_ value: BoxProps, into buf: inout [UInt8]) { - FfiConverterOptionTypeContentAlignment.write(value.contentAlignment, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBoxProps_lift(_ buf: RustBuffer) throws -> BoxProps { - return try FfiConverterTypeBoxProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBoxProps_lower(_ value: BoxProps) -> RustBuffer { - return FfiConverterTypeBoxProps.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::Button`]. - */ -public struct ButtonProps: Equatable, Hashable { - /** - * Button label text. - */ - public var text: String - /** - * Button style variant. - */ - public var variant: ButtonVariant? - /** - * Whether the button is enabled. Absent leaves the default to the host. - */ - public var enabled: OptionalBool - /** - * Whether the button shows a loading state. Absent leaves the default to the host. - */ - public var loading: OptionalBool - /** - * Action identifier triggered on click. - */ - public var clickAction: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Button label text. - */text: String, - /** - * Button style variant. - */variant: ButtonVariant?, - /** - * Whether the button is enabled. Absent leaves the default to the host. - */enabled: OptionalBool, - /** - * Whether the button shows a loading state. Absent leaves the default to the host. - */loading: OptionalBool, - /** - * Action identifier triggered on click. - */clickAction: String?) { - self.text = text - self.variant = variant - self.enabled = enabled - self.loading = loading - self.clickAction = clickAction - } - - - - -} - -#if compiler(>=6) -extension ButtonProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeButtonProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ButtonProps { - return - try ButtonProps( - text: FfiConverterString.read(from: &buf), - variant: FfiConverterOptionTypeButtonVariant.read(from: &buf), - enabled: FfiConverterTypeOptionalBool.read(from: &buf), - loading: FfiConverterTypeOptionalBool.read(from: &buf), - clickAction: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: ButtonProps, into buf: inout [UInt8]) { - FfiConverterString.write(value.text, into: &buf) - FfiConverterOptionTypeButtonVariant.write(value.variant, into: &buf) - FfiConverterTypeOptionalBool.write(value.enabled, into: &buf) - FfiConverterTypeOptionalBool.write(value.loading, into: &buf) - FfiConverterOptionString.write(value.clickAction, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeButtonProps_lift(_ buf: RustBuffer) throws -> ButtonProps { - return try FfiConverterTypeButtonProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeButtonProps_lower(_ value: ButtonProps) -> RustBuffer { - return FfiConverterTypeButtonProps.lower(value) -} - - -/** - * A clickable action button in a chat message. - */ -public struct ChatAction: Equatable, Hashable { - /** - * Action identifier. - */ - public var actionId: String - /** - * Button label. - */ - public var title: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Action identifier. - */actionId: String, - /** - * Button label. - */title: String) { - self.actionId = actionId - self.title = title - } - - - - -} - -#if compiler(>=6) -extension ChatAction: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatAction: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatAction { - return - try ChatAction( - actionId: FfiConverterString.read(from: &buf), - title: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: ChatAction, into buf: inout [UInt8]) { - FfiConverterString.write(value.actionId, into: &buf) - FfiConverterString.write(value.title, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatAction_lift(_ buf: RustBuffer) throws -> ChatAction { - return try FfiConverterTypeChatAction.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatAction_lower(_ value: ChatAction) -> RustBuffer { - return FfiConverterTypeChatAction.lower(value) -} - - -/** - * A set of action buttons with optional text. - */ -public struct ChatActions: Equatable, Hashable { - /** - * Optional message text. - */ - public var text: String? - /** - * List of action buttons. - */ - public var actions: [ChatAction] - /** - * `Column` or `Grid` layout. - */ - public var layout: ChatActionLayout - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Optional message text. - */text: String?, - /** - * List of action buttons. - */actions: [ChatAction], - /** - * `Column` or `Grid` layout. - */layout: ChatActionLayout) { - self.text = text - self.actions = actions - self.layout = layout - } - - - - -} - -#if compiler(>=6) -extension ChatActions: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatActions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatActions { - return - try ChatActions( - text: FfiConverterOptionString.read(from: &buf), - actions: FfiConverterSequenceTypeChatAction.read(from: &buf), - layout: FfiConverterTypeChatActionLayout.read(from: &buf) - ) - } - - public static func write(_ value: ChatActions, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.text, into: &buf) - FfiConverterSequenceTypeChatAction.write(value.actions, into: &buf) - FfiConverterTypeChatActionLayout.write(value.layout, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActions_lift(_ buf: RustBuffer) throws -> ChatActions { - return try FfiConverterTypeChatActions.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActions_lower(_ value: ChatActions) -> RustBuffer { - return FfiConverterTypeChatActions.lower(value) -} - - -/** - * A slash command from a chat user. - */ -public struct ChatCommand: Equatable, Hashable { - /** - * Command name. - */ - public var command: String - /** - * Command arguments. - */ - public var payload: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Command name. - */command: String, - /** - * Command arguments. - */payload: String) { - self.command = command - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension ChatCommand: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatCommand: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatCommand { - return - try ChatCommand( - command: FfiConverterString.read(from: &buf), - payload: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: ChatCommand, into buf: inout [UInt8]) { - FfiConverterString.write(value.command, into: &buf) - FfiConverterString.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatCommand_lift(_ buf: RustBuffer) throws -> ChatCommand { - return try FfiConverterTypeChatCommand.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatCommand_lower(_ value: ChatCommand) -> RustBuffer { - return FfiConverterTypeChatCommand.lower(value) -} - - -/** - * A custom message with application-defined type and binary payload. - */ -public struct ChatCustomMessage: Equatable, Hashable { - /** - * Application-defined type key. - */ - public var messageType: String - /** - * Binary payload. - */ - public var payload: Data - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Application-defined type key. - */messageType: String, - /** - * Binary payload. - */payload: Data) { - self.messageType = messageType - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension ChatCustomMessage: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatCustomMessage: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatCustomMessage { - return - try ChatCustomMessage( - messageType: FfiConverterString.read(from: &buf), - payload: FfiConverterData.read(from: &buf) - ) - } - - public static func write(_ value: ChatCustomMessage, into buf: inout [UInt8]) { - FfiConverterString.write(value.messageType, into: &buf) - FfiConverterData.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatCustomMessage_lift(_ buf: RustBuffer) throws -> ChatCustomMessage { - return try FfiConverterTypeChatCustomMessage.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatCustomMessage_lower(_ value: ChatCustomMessage) -> RustBuffer { - return FfiConverterTypeChatCustomMessage.lower(value) -} - - -/** - * A file attachment in a chat message. - */ -public struct ChatFile: Equatable, Hashable { - /** - * File download URL. - */ - public var url: String - /** - * File name. - */ - public var fileName: String - /** - * MIME type. - */ - public var mimeType: String - /** - * File size in bytes. - */ - public var sizeBytes: UInt64 - /** - * Optional caption text. - */ - public var text: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * File download URL. - */url: String, - /** - * File name. - */fileName: String, - /** - * MIME type. - */mimeType: String, - /** - * File size in bytes. - */sizeBytes: UInt64, - /** - * Optional caption text. - */text: String?) { - self.url = url - self.fileName = fileName - self.mimeType = mimeType - self.sizeBytes = sizeBytes - self.text = text - } - - - - -} - -#if compiler(>=6) -extension ChatFile: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatFile: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatFile { - return - try ChatFile( - url: FfiConverterString.read(from: &buf), - fileName: FfiConverterString.read(from: &buf), - mimeType: FfiConverterString.read(from: &buf), - sizeBytes: FfiConverterUInt64.read(from: &buf), - text: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: ChatFile, into buf: inout [UInt8]) { - FfiConverterString.write(value.url, into: &buf) - FfiConverterString.write(value.fileName, into: &buf) - FfiConverterString.write(value.mimeType, into: &buf) - FfiConverterUInt64.write(value.sizeBytes, into: &buf) - FfiConverterOptionString.write(value.text, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatFile_lift(_ buf: RustBuffer) throws -> ChatFile { - return try FfiConverterTypeChatFile.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatFile_lower(_ value: ChatFile) -> RustBuffer { - return FfiConverterTypeChatFile.lower(value) -} - - -/** - * A media attachment. - */ -public struct ChatMedia: Equatable, Hashable { - /** - * Media URL. - */ - public var url: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Media URL. - */url: String) { - self.url = url - } - - - - -} - -#if compiler(>=6) -extension ChatMedia: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatMedia: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatMedia { - return - try ChatMedia( - url: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: ChatMedia, into buf: inout [UInt8]) { - FfiConverterString.write(value.url, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatMedia_lift(_ buf: RustBuffer) throws -> ChatMedia { - return try FfiConverterTypeChatMedia.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatMedia_lower(_ value: ChatMedia) -> RustBuffer { - return FfiConverterTypeChatMedia.lower(value) -} - - -/** - * A reaction to a chat message. - */ -public struct ChatReaction: Equatable, Hashable { - /** - * Message being reacted to. - */ - public var messageId: String - /** - * Emoji reaction. - */ - public var emoji: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Message being reacted to. - */messageId: String, - /** - * Emoji reaction. - */emoji: String) { - self.messageId = messageId - self.emoji = emoji - } - - - - -} - -#if compiler(>=6) -extension ChatReaction: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatReaction: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatReaction { - return - try ChatReaction( - messageId: FfiConverterString.read(from: &buf), - emoji: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: ChatReaction, into buf: inout [UInt8]) { - FfiConverterString.write(value.messageId, into: &buf) - FfiConverterString.write(value.emoji, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatReaction_lift(_ buf: RustBuffer) throws -> ChatReaction { - return try FfiConverterTypeChatReaction.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatReaction_lower(_ value: ChatReaction) -> RustBuffer { - return FfiConverterTypeChatReaction.lower(value) -} - - -/** - * Rich text message with optional media. - */ -public struct ChatRichText: Equatable, Hashable { - /** - * Optional text content. - */ - public var text: String? - /** - * Attached media items. - */ - public var media: [ChatMedia] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Optional text content. - */text: String?, - /** - * Attached media items. - */media: [ChatMedia]) { - self.text = text - self.media = media - } - - - - -} - -#if compiler(>=6) -extension ChatRichText: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatRichText: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatRichText { - return - try ChatRichText( - text: FfiConverterOptionString.read(from: &buf), - media: FfiConverterSequenceTypeChatMedia.read(from: &buf) - ) - } - - public static func write(_ value: ChatRichText, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.text, into: &buf) - FfiConverterSequenceTypeChatMedia.write(value.media, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRichText_lift(_ buf: RustBuffer) throws -> ChatRichText { - return try FfiConverterTypeChatRichText.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRichText_lower(_ value: ChatRichText) -> RustBuffer { - return FfiConverterTypeChatRichText.lower(value) -} - - -/** - * A chat room the product participates in. - */ -public struct ChatRoom: Equatable, Hashable { - /** - * Room identifier. - */ - public var roomId: String - /** - * `RoomHost` or `Bot`. - */ - public var participatingAs: ChatRoomParticipation - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Room identifier. - */roomId: String, - /** - * `RoomHost` or `Bot`. - */participatingAs: ChatRoomParticipation) { - self.roomId = roomId - self.participatingAs = participatingAs - } - - - - -} - -#if compiler(>=6) -extension ChatRoom: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatRoom: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatRoom { - return - try ChatRoom( - roomId: FfiConverterString.read(from: &buf), - participatingAs: FfiConverterTypeChatRoomParticipation.read(from: &buf) - ) - } - - public static func write(_ value: ChatRoom, into buf: inout [UInt8]) { - FfiConverterString.write(value.roomId, into: &buf) - FfiConverterTypeChatRoomParticipation.write(value.participatingAs, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoom_lift(_ buf: RustBuffer) throws -> ChatRoom { - return try FfiConverterTypeChatRoom.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoom_lower(_ value: ChatRoom) -> RustBuffer { - return FfiConverterTypeChatRoom.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::Column`] layout. - */ -public struct ColumnProps: Equatable, Hashable { - /** - * Horizontal alignment of children. - */ - public var horizontalAlignment: HorizontalAlignment? - /** - * Vertical arrangement of children. - */ - public var verticalArrangement: Arrangement? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Horizontal alignment of children. - */horizontalAlignment: HorizontalAlignment?, - /** - * Vertical arrangement of children. - */verticalArrangement: Arrangement?) { - self.horizontalAlignment = horizontalAlignment - self.verticalArrangement = verticalArrangement - } - - - - -} - -#if compiler(>=6) -extension ColumnProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeColumnProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ColumnProps { - return - try ColumnProps( - horizontalAlignment: FfiConverterOptionTypeHorizontalAlignment.read(from: &buf), - verticalArrangement: FfiConverterOptionTypeArrangement.read(from: &buf) - ) - } - - public static func write(_ value: ColumnProps, into buf: inout [UInt8]) { - FfiConverterOptionTypeHorizontalAlignment.write(value.horizontalAlignment, into: &buf) - FfiConverterOptionTypeArrangement.write(value.verticalArrangement, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeColumnProps_lift(_ buf: RustBuffer) throws -> ColumnProps { - return try FfiConverterTypeColumnProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeColumnProps_lower(_ value: ColumnProps) -> RustBuffer { - return FfiConverterTypeColumnProps.lower(value) -} - - -/** - * CSS-like dimensions: (top, end, bottom, start). - * Bottom defaults to top, start defaults to end when `None`. - */ -public struct Dimensions: Equatable, Hashable { - /** - * Top dimension. - */ - public var top: Size - /** - * End dimension. - */ - public var end: Size - /** - * Bottom dimension. Defaults to top when absent. - */ - public var bottom: Size? - /** - * Start dimension. Defaults to end when absent. - */ - public var start: Size? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Top dimension. - */top: Size, - /** - * End dimension. - */end: Size, - /** - * Bottom dimension. Defaults to top when absent. - */bottom: Size?, - /** - * Start dimension. Defaults to end when absent. - */start: Size?) { - self.top = top - self.end = end - self.bottom = bottom - self.start = start - } - - - - -} - -#if compiler(>=6) -extension Dimensions: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeDimensions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Dimensions { - return - try Dimensions( - top: FfiConverterTypeSize.read(from: &buf), - end: FfiConverterTypeSize.read(from: &buf), - bottom: FfiConverterOptionTypeSize.read(from: &buf), - start: FfiConverterOptionTypeSize.read(from: &buf) - ) - } - - public static func write(_ value: Dimensions, into buf: inout [UInt8]) { - FfiConverterTypeSize.write(value.top, into: &buf) - FfiConverterTypeSize.write(value.end, into: &buf) - FfiConverterOptionTypeSize.write(value.bottom, into: &buf) - FfiConverterOptionTypeSize.write(value.start, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDimensions_lift(_ buf: RustBuffer) throws -> Dimensions { - return try FfiConverterTypeDimensions.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDimensions_lower(_ value: Dimensions) -> RustBuffer { - return FfiConverterTypeDimensions.lower(value) -} - - -/** - * Request to produce an sr25519 VRF signature from a product account over a - * caller-supplied Merlin transcript. - */ -public struct HostAccountSignVrfRequest: Equatable, Hashable { - /** - * Account whose key signs the VRF. - */ - public var account: ProductAccountId - /** - * Root domain-separation label: `Transcript::new(transcript_label)`. - */ - public var transcriptLabel: Data - /** - * Transcript items replayed in order as `append_message(label, value)`. - */ - public var items: [VrfTranscriptItem] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Account whose key signs the VRF. - */account: ProductAccountId, - /** - * Root domain-separation label: `Transcript::new(transcript_label)`. - */transcriptLabel: Data, - /** - * Transcript items replayed in order as `append_message(label, value)`. - */items: [VrfTranscriptItem]) { - self.account = account - self.transcriptLabel = transcriptLabel - self.items = items - } - - - - -} - -#if compiler(>=6) -extension HostAccountSignVrfRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostAccountSignVrfRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostAccountSignVrfRequest { - return - try HostAccountSignVrfRequest( - account: FfiConverterTypeProductAccountId.read(from: &buf), - transcriptLabel: FfiConverterData.read(from: &buf), - items: FfiConverterSequenceTypeVrfTranscriptItem.read(from: &buf) - ) - } - - public static func write(_ value: HostAccountSignVrfRequest, into buf: inout [UInt8]) { - FfiConverterTypeProductAccountId.write(value.account, into: &buf) - FfiConverterData.write(value.transcriptLabel, into: &buf) - FfiConverterSequenceTypeVrfTranscriptItem.write(value.items, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostAccountSignVrfRequest_lift(_ buf: RustBuffer) throws -> HostAccountSignVrfRequest { - return try FfiConverterTypeHostAccountSignVrfRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostAccountSignVrfRequest_lower(_ value: HostAccountSignVrfRequest) -> RustBuffer { - return FfiConverterTypeHostAccountSignVrfRequest.lower(value) -} - - -/** - * A chat action received from the host. - */ -public struct HostChatActionSubscribeItem: Equatable, Hashable { - /** - * Room where the action occurred. - */ - public var roomId: String - /** - * Peer who initiated the action. - */ - public var peer: String - /** - * The action payload. - */ - public var payload: ChatActionPayload - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Room where the action occurred. - */roomId: String, - /** - * Peer who initiated the action. - */peer: String, - /** - * The action payload. - */payload: ChatActionPayload) { - self.roomId = roomId - self.peer = peer - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension HostChatActionSubscribeItem: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostChatActionSubscribeItem: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostChatActionSubscribeItem { - return - try HostChatActionSubscribeItem( - roomId: FfiConverterString.read(from: &buf), - peer: FfiConverterString.read(from: &buf), - payload: FfiConverterTypeChatActionPayload.read(from: &buf) - ) - } - - public static func write(_ value: HostChatActionSubscribeItem, into buf: inout [UInt8]) { - FfiConverterString.write(value.roomId, into: &buf) - FfiConverterString.write(value.peer, into: &buf) - FfiConverterTypeChatActionPayload.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChatActionSubscribeItem_lift(_ buf: RustBuffer) throws -> HostChatActionSubscribeItem { - return try FfiConverterTypeHostChatActionSubscribeItem.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChatActionSubscribeItem_lower(_ value: HostChatActionSubscribeItem) -> RustBuffer { - return FfiConverterTypeHostChatActionSubscribeItem.lower(value) -} - - -/** - * Locale the host currently presents its interface in, pushed to subscribers. - */ -public struct HostLocaleSubscribeItem: Equatable, Hashable { - /** - * BCP 47 language tag, such as `en`, `pt-BR` or `zh-Hans`. The set is - * open: a product that does not ship the tag chooses its own fallback. - */ - public var languageTag: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * BCP 47 language tag, such as `en`, `pt-BR` or `zh-Hans`. The set is - * open: a product that does not ship the tag chooses its own fallback. - */languageTag: String) { - self.languageTag = languageTag - } - - - - -} - -#if compiler(>=6) -extension HostLocaleSubscribeItem: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostLocaleSubscribeItem: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostLocaleSubscribeItem { - return - try HostLocaleSubscribeItem( - languageTag: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: HostLocaleSubscribeItem, into buf: inout [UInt8]) { - FfiConverterString.write(value.languageTag, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostLocaleSubscribeItem_lift(_ buf: RustBuffer) throws -> HostLocaleSubscribeItem { - return try FfiConverterTypeHostLocaleSubscribeItem.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostLocaleSubscribeItem_lower(_ value: HostLocaleSubscribeItem) -> RustBuffer { - return FfiConverterTypeHostLocaleSubscribeItem.lower(value) -} - - -/** - * Push notification payload. - * - * When `scheduled_at` is `Some`, the notification is deferred to the given - * wall-clock instant (Unix milliseconds UTC). `None` fires immediately, - * preserving prior behaviour. See [RFC 0019]. - * - * [RFC 0019]: https://github.com/paritytech/host-rust-core/blob/main/docs/rfcs/0019-scheduled-notifications.md - */ -public struct HostPushNotificationRequest: Equatable, Hashable { - /** - * Notification text. - */ - public var text: String - /** - * Optional URL to open on tap. - */ - public var deeplink: String? - /** - * Optional Unix timestamp in milliseconds (UTC) at which the notification - * should fire. `None` fires immediately. - */ - public var scheduledAt: UInt64? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Notification text. - */text: String, - /** - * Optional URL to open on tap. - */deeplink: String?, - /** - * Optional Unix timestamp in milliseconds (UTC) at which the notification - * should fire. `None` fires immediately. - */scheduledAt: UInt64?) { - self.text = text - self.deeplink = deeplink - self.scheduledAt = scheduledAt - } - - - - -} - -#if compiler(>=6) -extension HostPushNotificationRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostPushNotificationRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostPushNotificationRequest { - return - try HostPushNotificationRequest( - text: FfiConverterString.read(from: &buf), - deeplink: FfiConverterOptionString.read(from: &buf), - scheduledAt: FfiConverterOptionUInt64.read(from: &buf) - ) - } - - public static func write(_ value: HostPushNotificationRequest, into buf: inout [UInt8]) { - FfiConverterString.write(value.text, into: &buf) - FfiConverterOptionString.write(value.deeplink, into: &buf) - FfiConverterOptionUInt64.write(value.scheduledAt, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostPushNotificationRequest_lift(_ buf: RustBuffer) throws -> HostPushNotificationRequest { - return try FfiConverterTypeHostPushNotificationRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostPushNotificationRequest_lower(_ value: HostPushNotificationRequest) -> RustBuffer { - return FfiConverterTypeHostPushNotificationRequest.lower(value) -} - - -/** - * Full Substrate extrinsic signing payload with all fields needed for signature - * generation. - */ -public struct HostSignPayloadData: Equatable, Hashable { - /** - * Reference block hash. - */ - public var blockHash: Data - /** - * Reference block number. - */ - public var blockNumber: Data - /** - * Mortality era encoding. - */ - public var era: Data - /** - * Chain genesis hash. - */ - public var genesisHash: Data - /** - * SCALE-encoded call data. - */ - public var method: Data - /** - * Account nonce. - */ - public var nonce: Data - /** - * Runtime spec version. - */ - public var specVersion: Data - /** - * Transaction tip. - */ - public var tip: Data - /** - * Transaction format version. - */ - public var transactionVersion: Data - /** - * Extension identifiers. - */ - public var signedExtensions: [String] - /** - * Extrinsic version. - */ - public var version: UInt32 - /** - * For multi-asset tips. - */ - public var assetId: Data? - /** - * CheckMetadataHash extension. - */ - public var metadataHash: Data? - /** - * Metadata mode. - */ - public var mode: UInt32? - /** - * Request signed transaction back. - */ - public var withSignedTransaction: Bool? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Reference block hash. - */blockHash: Data, - /** - * Reference block number. - */blockNumber: Data, - /** - * Mortality era encoding. - */era: Data, - /** - * Chain genesis hash. - */genesisHash: Data, - /** - * SCALE-encoded call data. - */method: Data, - /** - * Account nonce. - */nonce: Data, - /** - * Runtime spec version. - */specVersion: Data, - /** - * Transaction tip. - */tip: Data, - /** - * Transaction format version. - */transactionVersion: Data, - /** - * Extension identifiers. - */signedExtensions: [String], - /** - * Extrinsic version. - */version: UInt32, - /** - * For multi-asset tips. - */assetId: Data?, - /** - * CheckMetadataHash extension. - */metadataHash: Data?, - /** - * Metadata mode. - */mode: UInt32?, - /** - * Request signed transaction back. - */withSignedTransaction: Bool?) { - self.blockHash = blockHash - self.blockNumber = blockNumber - self.era = era - self.genesisHash = genesisHash - self.method = method - self.nonce = nonce - self.specVersion = specVersion - self.tip = tip - self.transactionVersion = transactionVersion - self.signedExtensions = signedExtensions - self.version = version - self.assetId = assetId - self.metadataHash = metadataHash - self.mode = mode - self.withSignedTransaction = withSignedTransaction - } - - - - -} - -#if compiler(>=6) -extension HostSignPayloadData: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostSignPayloadData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostSignPayloadData { - return - try HostSignPayloadData( - blockHash: FfiConverterData.read(from: &buf), - blockNumber: FfiConverterData.read(from: &buf), - era: FfiConverterData.read(from: &buf), - genesisHash: FfiConverterData.read(from: &buf), - method: FfiConverterData.read(from: &buf), - nonce: FfiConverterData.read(from: &buf), - specVersion: FfiConverterData.read(from: &buf), - tip: FfiConverterData.read(from: &buf), - transactionVersion: FfiConverterData.read(from: &buf), - signedExtensions: FfiConverterSequenceString.read(from: &buf), - version: FfiConverterUInt32.read(from: &buf), - assetId: FfiConverterOptionData.read(from: &buf), - metadataHash: FfiConverterOptionData.read(from: &buf), - mode: FfiConverterOptionUInt32.read(from: &buf), - withSignedTransaction: FfiConverterOptionBool.read(from: &buf) - ) - } - - public static func write(_ value: HostSignPayloadData, into buf: inout [UInt8]) { - FfiConverterData.write(value.blockHash, into: &buf) - FfiConverterData.write(value.blockNumber, into: &buf) - FfiConverterData.write(value.era, into: &buf) - FfiConverterData.write(value.genesisHash, into: &buf) - FfiConverterData.write(value.method, into: &buf) - FfiConverterData.write(value.nonce, into: &buf) - FfiConverterData.write(value.specVersion, into: &buf) - FfiConverterData.write(value.tip, into: &buf) - FfiConverterData.write(value.transactionVersion, into: &buf) - FfiConverterSequenceString.write(value.signedExtensions, into: &buf) - FfiConverterUInt32.write(value.version, into: &buf) - FfiConverterOptionData.write(value.assetId, into: &buf) - FfiConverterOptionData.write(value.metadataHash, into: &buf) - FfiConverterOptionUInt32.write(value.mode, into: &buf) - FfiConverterOptionBool.write(value.withSignedTransaction, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadData_lift(_ buf: RustBuffer) throws -> HostSignPayloadData { - return try FfiConverterTypeHostSignPayloadData.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadData_lower(_ value: HostSignPayloadData) -> RustBuffer { - return FfiConverterTypeHostSignPayloadData.lower(value) -} - - -/** - * Request to sign an extrinsic payload with a product account. - */ -public struct HostSignPayloadRequest: Equatable, Hashable { - /** - * Product account that will sign this payload. - */ - public var account: ProductAccountId - /** - * The extrinsic payload to sign. - */ - public var payload: HostSignPayloadData - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product account that will sign this payload. - */account: ProductAccountId, - /** - * The extrinsic payload to sign. - */payload: HostSignPayloadData) { - self.account = account - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension HostSignPayloadRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostSignPayloadRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostSignPayloadRequest { - return - try HostSignPayloadRequest( - account: FfiConverterTypeProductAccountId.read(from: &buf), - payload: FfiConverterTypeHostSignPayloadData.read(from: &buf) - ) - } - - public static func write(_ value: HostSignPayloadRequest, into buf: inout [UInt8]) { - FfiConverterTypeProductAccountId.write(value.account, into: &buf) - FfiConverterTypeHostSignPayloadData.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadRequest_lift(_ buf: RustBuffer) throws -> HostSignPayloadRequest { - return try FfiConverterTypeHostSignPayloadRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadRequest_lower(_ value: HostSignPayloadRequest) -> RustBuffer { - return FfiConverterTypeHostSignPayloadRequest.lower(value) -} - - -/** - * Sign a Substrate extrinsic payload with a non-product (legacy) account. - * Contains the same fields as [`HostSignPayloadRequest`] minus `address` - * (replaced by `signer`). - */ -public struct HostSignPayloadWithLegacyAccountRequest: Equatable, Hashable { - /** - * Signer address (SS58 or hex) of the legacy account. - */ - public var signer: String - /** - * The extrinsic payload to sign. - */ - public var payload: HostSignPayloadData - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Signer address (SS58 or hex) of the legacy account. - */signer: String, - /** - * The extrinsic payload to sign. - */payload: HostSignPayloadData) { - self.signer = signer - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension HostSignPayloadWithLegacyAccountRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostSignPayloadWithLegacyAccountRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostSignPayloadWithLegacyAccountRequest { - return - try HostSignPayloadWithLegacyAccountRequest( - signer: FfiConverterString.read(from: &buf), - payload: FfiConverterTypeHostSignPayloadData.read(from: &buf) - ) - } - - public static func write(_ value: HostSignPayloadWithLegacyAccountRequest, into buf: inout [UInt8]) { - FfiConverterString.write(value.signer, into: &buf) - FfiConverterTypeHostSignPayloadData.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadWithLegacyAccountRequest_lift(_ buf: RustBuffer) throws -> HostSignPayloadWithLegacyAccountRequest { - return try FfiConverterTypeHostSignPayloadWithLegacyAccountRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignPayloadWithLegacyAccountRequest_lower(_ value: HostSignPayloadWithLegacyAccountRequest) -> RustBuffer { - return FfiConverterTypeHostSignPayloadWithLegacyAccountRequest.lower(value) -} - - -/** - * A raw signing request pairing an account with the payload to sign. - */ -public struct HostSignRawRequest: Equatable, Hashable { - /** - * Product account that will sign this payload. - */ - public var account: ProductAccountId - /** - * The payload to sign. - */ - public var payload: RawPayload - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product account that will sign this payload. - */account: ProductAccountId, - /** - * The payload to sign. - */payload: RawPayload) { - self.account = account - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension HostSignRawRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostSignRawRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostSignRawRequest { - return - try HostSignRawRequest( - account: FfiConverterTypeProductAccountId.read(from: &buf), - payload: FfiConverterTypeRawPayload.read(from: &buf) - ) - } - - public static func write(_ value: HostSignRawRequest, into buf: inout [UInt8]) { - FfiConverterTypeProductAccountId.write(value.account, into: &buf) - FfiConverterTypeRawPayload.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignRawRequest_lift(_ buf: RustBuffer) throws -> HostSignRawRequest { - return try FfiConverterTypeHostSignRawRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignRawRequest_lower(_ value: HostSignRawRequest) -> RustBuffer { - return FfiConverterTypeHostSignRawRequest.lower(value) -} - - -/** - * Sign raw bytes with a non-product (legacy) account. The signer field - * identifies which legacy account to use. - */ -public struct HostSignRawWithLegacyAccountRequest: Equatable, Hashable { - /** - * Signer address (SS58 or hex) of the legacy account. - */ - public var signer: String - /** - * The data to sign. - */ - public var payload: RawPayload - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Signer address (SS58 or hex) of the legacy account. - */signer: String, - /** - * The data to sign. - */payload: RawPayload) { - self.signer = signer - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension HostSignRawWithLegacyAccountRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostSignRawWithLegacyAccountRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostSignRawWithLegacyAccountRequest { - return - try HostSignRawWithLegacyAccountRequest( - signer: FfiConverterString.read(from: &buf), - payload: FfiConverterTypeRawPayload.read(from: &buf) - ) - } - - public static func write(_ value: HostSignRawWithLegacyAccountRequest, into buf: inout [UInt8]) { - FfiConverterString.write(value.signer, into: &buf) - FfiConverterTypeRawPayload.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignRawWithLegacyAccountRequest_lift(_ buf: RustBuffer) throws -> HostSignRawWithLegacyAccountRequest { - return try FfiConverterTypeHostSignRawWithLegacyAccountRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostSignRawWithLegacyAccountRequest_lower(_ value: HostSignRawWithLegacyAccountRequest) -> RustBuffer { - return FfiConverterTypeHostSignRawWithLegacyAccountRequest.lower(value) -} - - -/** - * Current theme state pushed to subscribers. - */ -public struct HostThemeSubscribeItem: Equatable, Hashable { - /** - * Theme name. - */ - public var name: ThemeName - /** - * Light or dark variant. - */ - public var variant: ThemeVariant - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Theme name. - */name: ThemeName, - /** - * Light or dark variant. - */variant: ThemeVariant) { - self.name = name - self.variant = variant - } - - - - -} - -#if compiler(>=6) -extension HostThemeSubscribeItem: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostThemeSubscribeItem: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostThemeSubscribeItem { - return - try HostThemeSubscribeItem( - name: FfiConverterTypeThemeName.read(from: &buf), - variant: FfiConverterTypeThemeVariant.read(from: &buf) - ) - } - - public static func write(_ value: HostThemeSubscribeItem, into buf: inout [UInt8]) { - FfiConverterTypeThemeName.write(value.name, into: &buf) - FfiConverterTypeThemeVariant.write(value.variant, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostThemeSubscribeItem_lift(_ buf: RustBuffer) throws -> HostThemeSubscribeItem { - return try FfiConverterTypeHostThemeSubscribeItem.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostThemeSubscribeItem_lower(_ value: HostThemeSubscribeItem) -> RustBuffer { - return FfiConverterTypeHostThemeSubscribeItem.lower(value) -} - - -/** - * Transaction payload for a legacy (non-product) account. - * - * Identical to [`ProductAccountTxPayload`] except the signer is a raw - * 32-byte [`AccountId`]. - */ -public struct LegacyAccountTxPayload: Equatable, Hashable { - /** - * Raw 32-byte public key of the legacy account. - */ - public var signer: Bytes32 - /** - * Chain where the transaction will execute. - */ - public var genesisHash: Bytes32 - /** - * SCALE-encoded Call data. - */ - public var callData: Data - /** - * Transaction extensions supplied by the caller. - */ - public var extensions: [TxPayloadExtension] - /** - * 0 for Extrinsic V4, runtime-supported value for V5. - */ - public var txExtVersion: UInt8 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Raw 32-byte public key of the legacy account. - */signer: Bytes32, - /** - * Chain where the transaction will execute. - */genesisHash: Bytes32, - /** - * SCALE-encoded Call data. - */callData: Data, - /** - * Transaction extensions supplied by the caller. - */extensions: [TxPayloadExtension], - /** - * 0 for Extrinsic V4, runtime-supported value for V5. - */txExtVersion: UInt8) { - self.signer = signer - self.genesisHash = genesisHash - self.callData = callData - self.extensions = extensions - self.txExtVersion = txExtVersion - } - - - - -} - -#if compiler(>=6) -extension LegacyAccountTxPayload: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeLegacyAccountTxPayload: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LegacyAccountTxPayload { - return - try LegacyAccountTxPayload( - signer: FfiConverterTypeBytes32.read(from: &buf), - genesisHash: FfiConverterTypeBytes32.read(from: &buf), - callData: FfiConverterData.read(from: &buf), - extensions: FfiConverterSequenceTypeTxPayloadExtension.read(from: &buf), - txExtVersion: FfiConverterUInt8.read(from: &buf) - ) - } - - public static func write(_ value: LegacyAccountTxPayload, into buf: inout [UInt8]) { - FfiConverterTypeBytes32.write(value.signer, into: &buf) - FfiConverterTypeBytes32.write(value.genesisHash, into: &buf) - FfiConverterData.write(value.callData, into: &buf) - FfiConverterSequenceTypeTxPayloadExtension.write(value.extensions, into: &buf) - FfiConverterUInt8.write(value.txExtVersion, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeLegacyAccountTxPayload_lift(_ buf: RustBuffer) throws -> LegacyAccountTxPayload { - return try FfiConverterTypeLegacyAccountTxPayload.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeLegacyAccountTxPayload_lower(_ value: LegacyAccountTxPayload) -> RustBuffer { - return FfiConverterTypeLegacyAccountTxPayload.lower(value) -} - - -/** - * Identifies a product-specific account by combining a dotNS domain name with a - * derivation index. - */ -public struct ProductAccountId: Equatable, Hashable { - /** - * A dotNS domain name identifier (e.g., `"my-product.dot"`). - */ - public var dotNsIdentifier: String - /** - * Account selector within the product subtree. - */ - public var derivationIndex: DerivationIndex - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * A dotNS domain name identifier (e.g., `"my-product.dot"`). - */dotNsIdentifier: String, - /** - * Account selector within the product subtree. - */derivationIndex: DerivationIndex) { - self.dotNsIdentifier = dotNsIdentifier - self.derivationIndex = derivationIndex - } - - - - -} - -#if compiler(>=6) -extension ProductAccountId: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductAccountId: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductAccountId { - return - try ProductAccountId( - dotNsIdentifier: FfiConverterString.read(from: &buf), - derivationIndex: FfiConverterTypeDerivationIndex.read(from: &buf) - ) - } - - public static func write(_ value: ProductAccountId, into buf: inout [UInt8]) { - FfiConverterString.write(value.dotNsIdentifier, into: &buf) - FfiConverterTypeDerivationIndex.write(value.derivationIndex, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductAccountId_lift(_ buf: RustBuffer) throws -> ProductAccountId { - return try FfiConverterTypeProductAccountId.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductAccountId_lower(_ value: ProductAccountId) -> RustBuffer { - return FfiConverterTypeProductAccountId.lower(value) -} - - -/** - * Transaction payload for a product account. - * - * Contains everything the host needs to construct a signed extrinsic. - * The signer is a [`ProductAccountId`]; the host resolves the - * corresponding key pair through its account management layer. - */ -public struct ProductAccountTxPayload: Equatable, Hashable { - /** - * Product account that will sign the transaction. - */ - public var signer: ProductAccountId - /** - * Chain where the transaction will execute. - */ - public var genesisHash: Bytes32 - /** - * SCALE-encoded Call data. - */ - public var callData: Data - /** - * Transaction extensions supplied by the caller. - */ - public var extensions: [TxPayloadExtension] - /** - * 0 for Extrinsic V4, runtime-supported value for V5. - */ - public var txExtVersion: UInt8 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product account that will sign the transaction. - */signer: ProductAccountId, - /** - * Chain where the transaction will execute. - */genesisHash: Bytes32, - /** - * SCALE-encoded Call data. - */callData: Data, - /** - * Transaction extensions supplied by the caller. - */extensions: [TxPayloadExtension], - /** - * 0 for Extrinsic V4, runtime-supported value for V5. - */txExtVersion: UInt8) { - self.signer = signer - self.genesisHash = genesisHash - self.callData = callData - self.extensions = extensions - self.txExtVersion = txExtVersion - } - - - - -} - -#if compiler(>=6) -extension ProductAccountTxPayload: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductAccountTxPayload: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductAccountTxPayload { - return - try ProductAccountTxPayload( - signer: FfiConverterTypeProductAccountId.read(from: &buf), - genesisHash: FfiConverterTypeBytes32.read(from: &buf), - callData: FfiConverterData.read(from: &buf), - extensions: FfiConverterSequenceTypeTxPayloadExtension.read(from: &buf), - txExtVersion: FfiConverterUInt8.read(from: &buf) - ) - } - - public static func write(_ value: ProductAccountTxPayload, into buf: inout [UInt8]) { - FfiConverterTypeProductAccountId.write(value.signer, into: &buf) - FfiConverterTypeBytes32.write(value.genesisHash, into: &buf) - FfiConverterData.write(value.callData, into: &buf) - FfiConverterSequenceTypeTxPayloadExtension.write(value.extensions, into: &buf) - FfiConverterUInt8.write(value.txExtVersion, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductAccountTxPayload_lift(_ buf: RustBuffer) throws -> ProductAccountTxPayload { - return try FfiConverterTypeProductAccountTxPayload.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductAccountTxPayload_lower(_ value: ProductAccountTxPayload) -> RustBuffer { - return FfiConverterTypeProductAccountTxPayload.lower(value) -} - - -/** - * A product-scoped proof context: a product and a context within it. - * - * Hashed (with a `product//` prefix) into the 32-byte context bound - * to a ring VRF proof, so contexts cannot collide across products and the same - * member key under different contexts yields unlinkable aliases. - */ -public struct ProductProofContext: Equatable, Hashable { - /** - * dotNS product identifier (e.g. `"my-product.dot"`) scoping the context. - */ - public var productId: String - /** - * Selector distinguishing contexts within the product; expands to the - * same 32-byte derivation index as [`ProductAccountId::derivation_index`]. - */ - public var suffix: DerivationIndex - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * dotNS product identifier (e.g. `"my-product.dot"`) scoping the context. - */productId: String, - /** - * Selector distinguishing contexts within the product; expands to the - * same 32-byte derivation index as [`ProductAccountId::derivation_index`]. - */suffix: DerivationIndex) { - self.productId = productId - self.suffix = suffix - } - - - - -} - -#if compiler(>=6) -extension ProductProofContext: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductProofContext: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductProofContext { - return - try ProductProofContext( - productId: FfiConverterString.read(from: &buf), - suffix: FfiConverterTypeDerivationIndex.read(from: &buf) - ) - } - - public static func write(_ value: ProductProofContext, into buf: inout [UInt8]) { - FfiConverterString.write(value.productId, into: &buf) - FfiConverterTypeDerivationIndex.write(value.suffix, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductProofContext_lift(_ buf: RustBuffer) throws -> ProductProofContext { - return try FfiConverterTypeProductProofContext.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductProofContext_lower(_ value: ProductProofContext) -> RustBuffer { - return FfiConverterTypeProductProofContext.lower(value) -} - - -/** - * remote-permission request (RFC 0002). - */ -public struct RemotePermissionRequest: Equatable, Hashable { - /** - * Permission requested by the product. - */ - public var permission: RemotePermission - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Permission requested by the product. - */permission: RemotePermission) { - self.permission = permission - } - - - - -} - -#if compiler(>=6) -extension RemotePermissionRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRemotePermissionRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RemotePermissionRequest { - return - try RemotePermissionRequest( - permission: FfiConverterTypeRemotePermission.read(from: &buf) - ) - } - - public static func write(_ value: RemotePermissionRequest, into buf: inout [UInt8]) { - FfiConverterTypeRemotePermission.write(value.permission, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRemotePermissionRequest_lift(_ buf: RustBuffer) throws -> RemotePermissionRequest { - return try FfiConverterTypeRemotePermissionRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRemotePermissionRequest_lower(_ value: RemotePermissionRequest) -> RustBuffer { - return FfiConverterTypeRemotePermissionRequest.lower(value) -} - - -/** - * Locates a ring for ring VRF operations using only identifiers that are - * stable across membership changes. - */ -public struct RingLocation: Equatable, Hashable { - /** - * Genesis hash of the chain hosting the ring. - */ - public var chainId: Bytes32 - /** - * Path addressing the ring within the chain. - */ - public var junctions: [RingLocationJunction] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Genesis hash of the chain hosting the ring. - */chainId: Bytes32, - /** - * Path addressing the ring within the chain. - */junctions: [RingLocationJunction]) { - self.chainId = chainId - self.junctions = junctions - } - - - - -} - -#if compiler(>=6) -extension RingLocation: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRingLocation: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RingLocation { - return - try RingLocation( - chainId: FfiConverterTypeBytes32.read(from: &buf), - junctions: FfiConverterSequenceTypeRingLocationJunction.read(from: &buf) - ) - } - - public static func write(_ value: RingLocation, into buf: inout [UInt8]) { - FfiConverterTypeBytes32.write(value.chainId, into: &buf) - FfiConverterSequenceTypeRingLocationJunction.write(value.junctions, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRingLocation_lift(_ buf: RustBuffer) throws -> RingLocation { - return try FfiConverterTypeRingLocation.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRingLocation_lower(_ value: RingLocation) -> RustBuffer { - return FfiConverterTypeRingLocation.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::Row`] layout. - */ -public struct RowProps: Equatable, Hashable { - /** - * Vertical alignment of children. - */ - public var verticalAlignment: VerticalAlignment? - /** - * Horizontal arrangement of children. - */ - public var horizontalArrangement: Arrangement? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Vertical alignment of children. - */verticalAlignment: VerticalAlignment?, - /** - * Horizontal arrangement of children. - */horizontalArrangement: Arrangement?) { - self.verticalAlignment = verticalAlignment - self.horizontalArrangement = horizontalArrangement - } - - - - -} - -#if compiler(>=6) -extension RowProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRowProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RowProps { - return - try RowProps( - verticalAlignment: FfiConverterOptionTypeVerticalAlignment.read(from: &buf), - horizontalArrangement: FfiConverterOptionTypeArrangement.read(from: &buf) - ) - } - - public static func write(_ value: RowProps, into buf: inout [UInt8]) { - FfiConverterOptionTypeVerticalAlignment.write(value.verticalAlignment, into: &buf) - FfiConverterOptionTypeArrangement.write(value.horizontalArrangement, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRowProps_lift(_ buf: RustBuffer) throws -> RowProps { - return try FfiConverterTypeRowProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRowProps_lower(_ value: RowProps) -> RustBuffer { - return FfiConverterTypeRowProps.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::TextField`]. - */ -public struct TextFieldProps: Equatable, Hashable { - /** - * Current text value. - */ - public var text: String - /** - * Placeholder text. - */ - public var placeholder: String? - /** - * Field label. - */ - public var label: String? - /** - * Whether the field is enabled. Absent leaves the default to the host. - */ - public var enabled: OptionalBool - /** - * Action identifier triggered when the value changes. - */ - public var valueChangeAction: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Current text value. - */text: String, - /** - * Placeholder text. - */placeholder: String?, - /** - * Field label. - */label: String?, - /** - * Whether the field is enabled. Absent leaves the default to the host. - */enabled: OptionalBool, - /** - * Action identifier triggered when the value changes. - */valueChangeAction: String?) { - self.text = text - self.placeholder = placeholder - self.label = label - self.enabled = enabled - self.valueChangeAction = valueChangeAction - } - - - - -} - -#if compiler(>=6) -extension TextFieldProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTextFieldProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TextFieldProps { - return - try TextFieldProps( - text: FfiConverterString.read(from: &buf), - placeholder: FfiConverterOptionString.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - enabled: FfiConverterTypeOptionalBool.read(from: &buf), - valueChangeAction: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: TextFieldProps, into buf: inout [UInt8]) { - FfiConverterString.write(value.text, into: &buf) - FfiConverterOptionString.write(value.placeholder, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterTypeOptionalBool.write(value.enabled, into: &buf) - FfiConverterOptionString.write(value.valueChangeAction, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextFieldProps_lift(_ buf: RustBuffer) throws -> TextFieldProps { - return try FfiConverterTypeTextFieldProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextFieldProps_lower(_ value: TextFieldProps) -> RustBuffer { - return FfiConverterTypeTextFieldProps.lower(value) -} - - -/** - * Properties for a [`CustomRendererNode::Text`] display. - */ -public struct TextProps: Equatable, Hashable { - /** - * Typography preset. - */ - public var style: TypographyStyle? - /** - * Text color. - */ - public var color: ColorToken? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Typography preset. - */style: TypographyStyle?, - /** - * Text color. - */color: ColorToken?) { - self.style = style - self.color = color - } - - - - -} - -#if compiler(>=6) -extension TextProps: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTextProps: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TextProps { - return - try TextProps( - style: FfiConverterOptionTypeTypographyStyle.read(from: &buf), - color: FfiConverterOptionTypeColorToken.read(from: &buf) - ) - } - - public static func write(_ value: TextProps, into buf: inout [UInt8]) { - FfiConverterOptionTypeTypographyStyle.write(value.style, into: &buf) - FfiConverterOptionTypeColorToken.write(value.color, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextProps_lift(_ buf: RustBuffer) throws -> TextProps { - return try FfiConverterTypeTextProps.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextProps_lower(_ value: TextProps) -> RustBuffer { - return FfiConverterTypeTextProps.lower(value) -} - - -/** - * A signed extension for a transaction payload. - */ -public struct TxPayloadExtension: Equatable, Hashable { - /** - * Extension name (e.g., `"CheckSpecVersion"`). - */ - public var id: String - /** - * SCALE-encoded extra data (in extrinsic body). - */ - public var extra: Data - /** - * SCALE-encoded implicit data (signed, not in body). - */ - public var additionalSigned: Data - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Extension name (e.g., `"CheckSpecVersion"`). - */id: String, - /** - * SCALE-encoded extra data (in extrinsic body). - */extra: Data, - /** - * SCALE-encoded implicit data (signed, not in body). - */additionalSigned: Data) { - self.id = id - self.extra = extra - self.additionalSigned = additionalSigned - } - - - - -} - -#if compiler(>=6) -extension TxPayloadExtension: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTxPayloadExtension: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxPayloadExtension { - return - try TxPayloadExtension( - id: FfiConverterString.read(from: &buf), - extra: FfiConverterData.read(from: &buf), - additionalSigned: FfiConverterData.read(from: &buf) - ) - } - - public static func write(_ value: TxPayloadExtension, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterData.write(value.extra, into: &buf) - FfiConverterData.write(value.additionalSigned, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTxPayloadExtension_lift(_ buf: RustBuffer) throws -> TxPayloadExtension { - return try FfiConverterTypeTxPayloadExtension.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTxPayloadExtension_lower(_ value: TxPayloadExtension) -> RustBuffer { - return FfiConverterTypeTxPayloadExtension.lower(value) -} - - -/** - * One `append_message` call replayed against the signing transcript. - */ -public struct VrfTranscriptItem: Equatable, Hashable { - /** - * Merlin `append_message` label. - */ - public var label: Data - /** - * Merlin `append_message` value. - */ - public var value: Data - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Merlin `append_message` label. - */label: Data, - /** - * Merlin `append_message` value. - */value: Data) { - self.label = label - self.value = value - } - - - - -} - -#if compiler(>=6) -extension VrfTranscriptItem: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeVrfTranscriptItem: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VrfTranscriptItem { - return - try VrfTranscriptItem( - label: FfiConverterData.read(from: &buf), - value: FfiConverterData.read(from: &buf) - ) - } - - public static func write(_ value: VrfTranscriptItem, into buf: inout [UInt8]) { - FfiConverterData.write(value.label, into: &buf) - FfiConverterData.write(value.value, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVrfTranscriptItem_lift(_ buf: RustBuffer) throws -> VrfTranscriptItem { - return try FfiConverterTypeVrfTranscriptItem.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVrfTranscriptItem_lower(_ value: VrfTranscriptItem) -> RustBuffer { - return FfiConverterTypeVrfTranscriptItem.lower(value) -} - - -/** - * A resource the host can pre-allocate on behalf of the product (RFC 0010). - * - * For the slot-table allowances (`StatementStoreAllowance`, - * `BulletinAllowance`, `SmartContractAllowance`), pre-allocation is - * opportunistic and the host may also fulfil the allowance implicitly on the - * first submission. `AutoSigning` must be requested explicitly through this - * call. - */ - -public enum AllocatableResource: Equatable, Hashable { - - /** - * Statement Store slot allowance for the product's own allowance account. - */ - case statementStoreAllowance - /** - * Bulletin chain slot allowance for the product's own allowance account. - */ - case bulletinAllowance - /** - * Pre-warmed PGAS balance for the product account selected by this - * derivation index. - */ - case smartContractAllowance(DerivationIndex - ) - /** - * Permission to sign on the product's behalf without per-call user prompts. - */ - case autoSigning - - - - - -} - -#if compiler(>=6) -extension AllocatableResource: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAllocatableResource: FfiConverterRustBuffer { - typealias SwiftType = AllocatableResource - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AllocatableResource { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .statementStoreAllowance - - case 2: return .bulletinAllowance - - case 3: return .smartContractAllowance(try FfiConverterTypeDerivationIndex.read(from: &buf) - ) - - case 4: return .autoSigning - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: AllocatableResource, into buf: inout [UInt8]) { - switch value { - - - case .statementStoreAllowance: - writeInt(&buf, Int32(1)) - - - case .bulletinAllowance: - writeInt(&buf, Int32(2)) - - - case let .smartContractAllowance(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeDerivationIndex.write(v1, into: &buf) - - - case .autoSigning: - writeInt(&buf, Int32(4)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAllocatableResource_lift(_ buf: RustBuffer) throws -> AllocatableResource { - return try FfiConverterTypeAllocatableResource.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAllocatableResource_lower(_ value: AllocatableResource) -> RustBuffer { - return FfiConverterTypeAllocatableResource.lower(value) -} - - - -/** - * Layout arrangement (like CSS flexbox `justify-content`). - */ - -public enum Arrangement: Equatable, Hashable { - - /** - * Pack children at the start. - */ - case start - /** - * Pack children at the end. - */ - case end - /** - * Pack children in the center. - */ - case center - /** - * Distribute with space between children. - */ - case spaceBetween - /** - * Distribute with space around each child. - */ - case spaceAround - /** - * Distribute with equal space between and around children. - */ - case spaceEvenly - - - - - -} - -#if compiler(>=6) -extension Arrangement: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeArrangement: FfiConverterRustBuffer { - typealias SwiftType = Arrangement - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Arrangement { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .start - - case 2: return .end - - case 3: return .center - - case 4: return .spaceBetween - - case 5: return .spaceAround - - case 6: return .spaceEvenly - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: Arrangement, into buf: inout [UInt8]) { - switch value { - - - case .start: - writeInt(&buf, Int32(1)) - - - case .end: - writeInt(&buf, Int32(2)) - - - case .center: - writeInt(&buf, Int32(3)) - - - case .spaceBetween: - writeInt(&buf, Int32(4)) - - - case .spaceAround: - writeInt(&buf, Int32(5)) - - - case .spaceEvenly: - writeInt(&buf, Int32(6)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeArrangement_lift(_ buf: RustBuffer) throws -> Arrangement { - return try FfiConverterTypeArrangement.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeArrangement_lower(_ value: Arrangement) -> RustBuffer { - return FfiConverterTypeArrangement.lower(value) -} - - - -/** - * Button style variants. - */ - -public enum ButtonVariant: Equatable, Hashable { - - /** - * Emphasized button for the primary action. - */ - case primary - /** - * De-emphasized button for secondary actions. - */ - case secondary - /** - * Text-only button without a background. - */ - case text - - - - - -} - -#if compiler(>=6) -extension ButtonVariant: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeButtonVariant: FfiConverterRustBuffer { - typealias SwiftType = ButtonVariant - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ButtonVariant { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .primary - - case 2: return .secondary - - case 3: return .text - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ButtonVariant, into buf: inout [UInt8]) { - switch value { - - - case .primary: - writeInt(&buf, Int32(1)) - - - case .secondary: - writeInt(&buf, Int32(2)) - - - case .text: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeButtonVariant_lift(_ buf: RustBuffer) throws -> ButtonVariant { - return try FfiConverterTypeButtonVariant.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeButtonVariant_lower(_ value: ButtonVariant) -> RustBuffer { - return FfiConverterTypeButtonVariant.lower(value) -} - - - -/** - * Role of a chain within the host's configured environment. - */ - -public enum ChainIdentifier: Equatable, Hashable { - - /** - * The relay chain. - */ - case relay - /** - * The asset hub system chain. - */ - case assetHub - /** - * The people chain. - */ - case people - /** - * The bulletin chain. - */ - case bulletin - - - - - -} - -#if compiler(>=6) -extension ChainIdentifier: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainIdentifier: FfiConverterRustBuffer { - typealias SwiftType = ChainIdentifier - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainIdentifier { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .relay - - case 2: return .assetHub - - case 3: return .people - - case 4: return .bulletin - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChainIdentifier, into buf: inout [UInt8]) { - switch value { - - - case .relay: - writeInt(&buf, Int32(1)) - - - case .assetHub: - writeInt(&buf, Int32(2)) - - - case .people: - writeInt(&buf, Int32(3)) - - - case .bulletin: - writeInt(&buf, Int32(4)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainIdentifier_lift(_ buf: RustBuffer) throws -> ChainIdentifier { - return try FfiConverterTypeChainIdentifier.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainIdentifier_lower(_ value: ChainIdentifier) -> RustBuffer { - return FfiConverterTypeChainIdentifier.lower(value) -} - - - -/** - * Layout for action buttons. - */ - -public enum ChatActionLayout: Equatable, Hashable { - - /** - * Buttons stacked vertically. - */ - case column - /** - * Buttons arranged in a grid. - */ - case grid - - - - - -} - -#if compiler(>=6) -extension ChatActionLayout: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatActionLayout: FfiConverterRustBuffer { - typealias SwiftType = ChatActionLayout - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatActionLayout { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .column - - case 2: return .grid - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatActionLayout, into buf: inout [UInt8]) { - switch value { - - - case .column: - writeInt(&buf, Int32(1)) - - - case .grid: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActionLayout_lift(_ buf: RustBuffer) throws -> ChatActionLayout { - return try FfiConverterTypeChatActionLayout.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActionLayout_lower(_ value: ChatActionLayout) -> RustBuffer { - return FfiConverterTypeChatActionLayout.lower(value) -} - - - -/** - * Payload of a received chat action. - */ - -public enum ChatActionPayload: Equatable, Hashable { - - /** - * A peer posted a message. - */ - case messagePosted(ChatMessageContent - ) - /** - * A user triggered an action button. - */ - case actionTriggered(ActionTrigger - ) - /** - * A user issued a command. - */ - case command(ChatCommand - ) - - - - - -} - -#if compiler(>=6) -extension ChatActionPayload: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatActionPayload: FfiConverterRustBuffer { - typealias SwiftType = ChatActionPayload - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatActionPayload { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .messagePosted(try FfiConverterTypeChatMessageContent.read(from: &buf) - ) - - case 2: return .actionTriggered(try FfiConverterTypeActionTrigger.read(from: &buf) - ) - - case 3: return .command(try FfiConverterTypeChatCommand.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatActionPayload, into buf: inout [UInt8]) { - switch value { - - - case let .messagePosted(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeChatMessageContent.write(v1, into: &buf) - - - case let .actionTriggered(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeActionTrigger.write(v1, into: &buf) - - - case let .command(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeChatCommand.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActionPayload_lift(_ buf: RustBuffer) throws -> ChatActionPayload { - return try FfiConverterTypeChatActionPayload.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatActionPayload_lower(_ value: ChatActionPayload) -> RustBuffer { - return FfiConverterTypeChatActionPayload.lower(value) -} - - - -/** - * Whether the bot was newly registered or already existed. - */ - -public enum ChatBotRegistrationStatus: Equatable, Hashable { - - /** - * The bot was registered. - */ - case new - /** - * A bot with this ID already existed. - */ - case exists - - - - - -} - -#if compiler(>=6) -extension ChatBotRegistrationStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatBotRegistrationStatus: FfiConverterRustBuffer { - typealias SwiftType = ChatBotRegistrationStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatBotRegistrationStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .new - - case 2: return .exists - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatBotRegistrationStatus, into buf: inout [UInt8]) { - switch value { - - - case .new: - writeInt(&buf, Int32(1)) - - - case .exists: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatBotRegistrationStatus_lift(_ buf: RustBuffer) throws -> ChatBotRegistrationStatus { - return try FfiConverterTypeChatBotRegistrationStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatBotRegistrationStatus_lower(_ value: ChatBotRegistrationStatus) -> RustBuffer { - return FfiConverterTypeChatBotRegistrationStatus.lower(value) -} - - - -/** - * Content of a chat message -- one of several types. - */ - -public enum ChatMessageContent: Equatable, Hashable { - - /** - * Plain text message. - */ - case text( - /** - * Message text. - */text: String - ) - /** - * Rich text with media. - */ - case richText(ChatRichText - ) - /** - * Action button set. - */ - case actions(ChatActions - ) - /** - * File attachment. - */ - case file(ChatFile - ) - /** - * Emoji reaction. - */ - case reaction(ChatReaction - ) - /** - * Reaction removal. - */ - case reactionRemoved(ChatReaction - ) - /** - * Custom message. - */ - case custom(ChatCustomMessage - ) - - - - - -} - -#if compiler(>=6) -extension ChatMessageContent: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatMessageContent: FfiConverterRustBuffer { - typealias SwiftType = ChatMessageContent - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatMessageContent { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .text(text: try FfiConverterString.read(from: &buf) - ) - - case 2: return .richText(try FfiConverterTypeChatRichText.read(from: &buf) - ) - - case 3: return .actions(try FfiConverterTypeChatActions.read(from: &buf) - ) - - case 4: return .file(try FfiConverterTypeChatFile.read(from: &buf) - ) - - case 5: return .reaction(try FfiConverterTypeChatReaction.read(from: &buf) - ) - - case 6: return .reactionRemoved(try FfiConverterTypeChatReaction.read(from: &buf) - ) - - case 7: return .custom(try FfiConverterTypeChatCustomMessage.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatMessageContent, into buf: inout [UInt8]) { - switch value { - - - case let .text(text): - writeInt(&buf, Int32(1)) - FfiConverterString.write(text, into: &buf) - - - case let .richText(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeChatRichText.write(v1, into: &buf) - - - case let .actions(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeChatActions.write(v1, into: &buf) - - - case let .file(v1): - writeInt(&buf, Int32(4)) - FfiConverterTypeChatFile.write(v1, into: &buf) - - - case let .reaction(v1): - writeInt(&buf, Int32(5)) - FfiConverterTypeChatReaction.write(v1, into: &buf) - - - case let .reactionRemoved(v1): - writeInt(&buf, Int32(6)) - FfiConverterTypeChatReaction.write(v1, into: &buf) - - - case let .custom(v1): - writeInt(&buf, Int32(7)) - FfiConverterTypeChatCustomMessage.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatMessageContent_lift(_ buf: RustBuffer) throws -> ChatMessageContent { - return try FfiConverterTypeChatMessageContent.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatMessageContent_lower(_ value: ChatMessageContent) -> RustBuffer { - return FfiConverterTypeChatMessageContent.lower(value) -} - - - -/** - * How the product participates in a chat room. - */ - -public enum ChatRoomParticipation: Equatable, Hashable { - - /** - * The product owns and hosts the room. - */ - case roomHost - /** - * The product participates as a registered bot. - */ - case bot - - - - - -} - -#if compiler(>=6) -extension ChatRoomParticipation: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatRoomParticipation: FfiConverterRustBuffer { - typealias SwiftType = ChatRoomParticipation - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatRoomParticipation { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .roomHost - - case 2: return .bot - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatRoomParticipation, into buf: inout [UInt8]) { - switch value { - - - case .roomHost: - writeInt(&buf, Int32(1)) - - - case .bot: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoomParticipation_lift(_ buf: RustBuffer) throws -> ChatRoomParticipation { - return try FfiConverterTypeChatRoomParticipation.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoomParticipation_lower(_ value: ChatRoomParticipation) -> RustBuffer { - return FfiConverterTypeChatRoomParticipation.lower(value) -} - - - -/** - * Whether the room was newly created or already existed. - */ - -public enum ChatRoomRegistrationStatus: Equatable, Hashable { - - /** - * The room was created. - */ - case new - /** - * A room with this ID already existed. - */ - case exists - - - - - -} - -#if compiler(>=6) -extension ChatRoomRegistrationStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChatRoomRegistrationStatus: FfiConverterRustBuffer { - typealias SwiftType = ChatRoomRegistrationStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChatRoomRegistrationStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .new - - case 2: return .exists - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChatRoomRegistrationStatus, into buf: inout [UInt8]) { - switch value { - - - case .new: - writeInt(&buf, Int32(1)) - - - case .exists: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoomRegistrationStatus_lift(_ buf: RustBuffer) throws -> ChatRoomRegistrationStatus { - return try FfiConverterTypeChatRoomRegistrationStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChatRoomRegistrationStatus_lower(_ value: ChatRoomRegistrationStatus) -> RustBuffer { - return FfiConverterTypeChatRoomRegistrationStatus.lower(value) -} - - - -/** - * Semantic color tokens for theming. - */ - -public enum ColorToken: Equatable, Hashable { - - /** - * Primary foreground (text) color. - */ - case fgPrimary - /** - * Secondary foreground color. - */ - case fgSecondary - /** - * Tertiary foreground color. - */ - case fgTertiary - /** - * Main surface background. - */ - case bgSurfaceMain - /** - * Container surface background. - */ - case bgSurfaceContainer - /** - * Nested surface background. - */ - case bgSurfaceNested - /** - * Foreground color for success states. - */ - case fgSuccess - /** - * Foreground color for error states. - */ - case fgError - /** - * Foreground color for warning states. - */ - case fgWarning - - - - - -} - -#if compiler(>=6) -extension ColorToken: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeColorToken: FfiConverterRustBuffer { - typealias SwiftType = ColorToken - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ColorToken { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .fgPrimary - - case 2: return .fgSecondary - - case 3: return .fgTertiary - - case 4: return .bgSurfaceMain - - case 5: return .bgSurfaceContainer - - case 6: return .bgSurfaceNested - - case 7: return .fgSuccess - - case 8: return .fgError - - case 9: return .fgWarning - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ColorToken, into buf: inout [UInt8]) { - switch value { - - - case .fgPrimary: - writeInt(&buf, Int32(1)) - - - case .fgSecondary: - writeInt(&buf, Int32(2)) - - - case .fgTertiary: - writeInt(&buf, Int32(3)) - - - case .bgSurfaceMain: - writeInt(&buf, Int32(4)) - - - case .bgSurfaceContainer: - writeInt(&buf, Int32(5)) - - - case .bgSurfaceNested: - writeInt(&buf, Int32(6)) - - - case .fgSuccess: - writeInt(&buf, Int32(7)) - - - case .fgError: - writeInt(&buf, Int32(8)) - - - case .fgWarning: - writeInt(&buf, Int32(9)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeColorToken_lift(_ buf: RustBuffer) throws -> ColorToken { - return try FfiConverterTypeColorToken.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeColorToken_lower(_ value: ColorToken) -> RustBuffer { - return FfiConverterTypeColorToken.lower(value) -} - - - -/** - * 2D content alignment. - */ - -public enum ContentAlignment: Equatable, Hashable { - - /** - * Top edge, start side. - */ - case topStart - /** - * Top edge, horizontally centered. - */ - case topCenter - /** - * Top edge, end side. - */ - case topEnd - /** - * Vertically centered, start side. - */ - case centerStart - /** - * Centered on both axes. - */ - case center - /** - * Vertically centered, end side. - */ - case centerEnd - /** - * Bottom edge, start side. - */ - case bottomStart - /** - * Bottom edge, horizontally centered. - */ - case bottomCenter - /** - * Bottom edge, end side. - */ - case bottomEnd - - - - - -} - -#if compiler(>=6) -extension ContentAlignment: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeContentAlignment: FfiConverterRustBuffer { - typealias SwiftType = ContentAlignment - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContentAlignment { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .topStart - - case 2: return .topCenter - - case 3: return .topEnd - - case 4: return .centerStart - - case 5: return .center - - case 6: return .centerEnd - - case 7: return .bottomStart - - case 8: return .bottomCenter - - case 9: return .bottomEnd - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ContentAlignment, into buf: inout [UInt8]) { - switch value { - - - case .topStart: - writeInt(&buf, Int32(1)) - - - case .topCenter: - writeInt(&buf, Int32(2)) - - - case .topEnd: - writeInt(&buf, Int32(3)) - - - case .centerStart: - writeInt(&buf, Int32(4)) - - - case .center: - writeInt(&buf, Int32(5)) - - - case .centerEnd: - writeInt(&buf, Int32(6)) - - - case .bottomStart: - writeInt(&buf, Int32(7)) - - - case .bottomCenter: - writeInt(&buf, Int32(8)) - - - case .bottomEnd: - writeInt(&buf, Int32(9)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeContentAlignment_lift(_ buf: RustBuffer) throws -> ContentAlignment { - return try FfiConverterTypeContentAlignment.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeContentAlignment_lower(_ value: ContentAlignment) -> RustBuffer { - return FfiConverterTypeContentAlignment.lower(value) -} - - - -/** - * A node in the custom renderer UI tree. Component variants contain recursive - * `children` fields. - */ - -public indirect enum CustomRendererNode: Equatable, Hashable { - - /** - * Empty node. - */ - case `nil` - /** - * Raw text string. - */ - case string( - /** - * Raw text. - */text: String - ) - /** - * Generic container. - */ - case box( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Box properties. - */props: BoxProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Vertical layout. - */ - case column( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Column properties. - */props: ColumnProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Horizontal layout. - */ - case row( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Row properties. - */props: RowProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Flexible space. - */ - case spacer( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Text display. - */ - case text( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Text properties. - */props: TextProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Interactive button. - */ - case button( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Button properties. - */props: ButtonProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - /** - * Text input. - */ - case textField( - /** - * Layout and styling modifiers. - */modifiers: [Modifier], - /** - * Text-field properties. - */props: TextFieldProps, - /** - * Child nodes. - */children: [CustomRendererNode] - ) - - - - - -} - -#if compiler(>=6) -extension CustomRendererNode: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeCustomRendererNode: FfiConverterRustBuffer { - typealias SwiftType = CustomRendererNode - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CustomRendererNode { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .`nil` - - case 2: return .string(text: try FfiConverterString.read(from: &buf) - ) - - case 3: return .box(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeBoxProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 4: return .column(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeColumnProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 5: return .row(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeRowProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 6: return .spacer(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 7: return .text(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeTextProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 8: return .button(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeButtonProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - case 9: return .textField(modifiers: try FfiConverterSequenceTypeModifier.read(from: &buf), props: try FfiConverterTypeTextFieldProps.read(from: &buf), children: try FfiConverterSequenceTypeCustomRendererNode.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: CustomRendererNode, into buf: inout [UInt8]) { - switch value { - - - case .`nil`: - writeInt(&buf, Int32(1)) - - - case let .string(text): - writeInt(&buf, Int32(2)) - FfiConverterString.write(text, into: &buf) - - - case let .box(modifiers,props,children): - writeInt(&buf, Int32(3)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeBoxProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .column(modifiers,props,children): - writeInt(&buf, Int32(4)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeColumnProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .row(modifiers,props,children): - writeInt(&buf, Int32(5)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeRowProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .spacer(modifiers,children): - writeInt(&buf, Int32(6)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .text(modifiers,props,children): - writeInt(&buf, Int32(7)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeTextProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .button(modifiers,props,children): - writeInt(&buf, Int32(8)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeButtonProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - - case let .textField(modifiers,props,children): - writeInt(&buf, Int32(9)) - FfiConverterSequenceTypeModifier.write(modifiers, into: &buf) - FfiConverterTypeTextFieldProps.write(props, into: &buf) - FfiConverterSequenceTypeCustomRendererNode.write(children, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCustomRendererNode_lift(_ buf: RustBuffer) throws -> CustomRendererNode { - return try FfiConverterTypeCustomRendererNode.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCustomRendererNode_lower(_ value: CustomRendererNode) -> RustBuffer { - return FfiConverterTypeCustomRendererNode.lower(value) -} - - - -/** - * Account selector within a product subtree. Encodes as - * `Either` on the wire (`Index` = left, `Raw` = right). - * - * `Index` is the primary form — plain indices keep a product's accounts - * enumerable. `Raw` carries a raw 32-byte derivation index for cases where - * bytes are genuinely necessary. Hosts expand `Index(n)` to the internal - * 32-byte index (`u32` little-endian plus the index magic). - */ - -public enum DerivationIndex: Equatable, Hashable { - - /** - * Plain account index. - */ - case index(UInt32 - ) - /** - * Raw 32-byte derivation index. - */ - case raw(Bytes32 - ) - - - - - -} - -#if compiler(>=6) -extension DerivationIndex: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeDerivationIndex: FfiConverterRustBuffer { - typealias SwiftType = DerivationIndex - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DerivationIndex { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .index(try FfiConverterUInt32.read(from: &buf) - ) - - case 2: return .raw(try FfiConverterTypeBytes32.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: DerivationIndex, into buf: inout [UInt8]) { - switch value { - - - case let .index(v1): - writeInt(&buf, Int32(1)) - FfiConverterUInt32.write(v1, into: &buf) - - - case let .raw(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeBytes32.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDerivationIndex_lift(_ buf: RustBuffer) throws -> DerivationIndex { - return try FfiConverterTypeDerivationIndex.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDerivationIndex_lower(_ value: DerivationIndex) -> RustBuffer { - return FfiConverterTypeDerivationIndex.lower(value) -} - - - -/** - * Horizontal alignment options. - */ - -public enum HorizontalAlignment: Equatable, Hashable { - - /** - * Align to the start edge. - */ - case start - /** - * Center horizontally. - */ - case center - /** - * Align to the end edge. - */ - case end - - - - - -} - -#if compiler(>=6) -extension HorizontalAlignment: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHorizontalAlignment: FfiConverterRustBuffer { - typealias SwiftType = HorizontalAlignment - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HorizontalAlignment { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .start - - case 2: return .center - - case 3: return .end - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HorizontalAlignment, into buf: inout [UInt8]) { - switch value { - - - case .start: - writeInt(&buf, Int32(1)) - - - case .center: - writeInt(&buf, Int32(2)) - - - case .end: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHorizontalAlignment_lift(_ buf: RustBuffer) throws -> HorizontalAlignment { - return try FfiConverterTypeHorizontalAlignment.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHorizontalAlignment_lower(_ value: HorizontalAlignment) -> RustBuffer { - return FfiConverterTypeHorizontalAlignment.lower(value) -} - - - -/** - * Device-capability permission requested from the host (RFC 0002). - * - * The user's decision is persisted indefinitely after the first prompt and - * survives app restarts, whether the decision was grant or deny; the host - * does not re-prompt on subsequent requests for the same capability. - * - * That decision is about this product. The OS grant behind it belongs to the - * host application and can move independently, so a host that can read OS - * state has the capability resolve only while both allow it: a stored grant - * whose OS grant was revoked answers `granted: false` without a prompt. An OS - * grant that is merely undetermined does not change the answer, because the OS - * resolves its own gate when the capability is used. - */ - -public enum HostDevicePermissionRequest: Equatable, Hashable { - - /** - * Showing system notifications. - */ - case notifications - /** - * Camera capture access. - */ - case camera - /** - * Microphone capture access. - */ - case microphone - /** - * Bluetooth device access. - */ - case bluetooth - /** - * NFC reader access. - */ - case nfc - /** - * Geolocation access. - */ - case location - /** - * Clipboard access. - */ - case clipboard - /** - * Handing a URL to the operating system, leaving the host application - * entirely. Requestable and persistable, but the core enforces nothing with - * it: *which* hosts a product may send the user to is - * `RemotePermission::Remote`, wherever the destination ends up opening. - */ - case openUrl - /** - * Biometric authentication. - */ - case biometrics - - - - - -} - -#if compiler(>=6) -extension HostDevicePermissionRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostDevicePermissionRequest: FfiConverterRustBuffer { - typealias SwiftType = HostDevicePermissionRequest - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostDevicePermissionRequest { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .notifications - - case 2: return .camera - - case 3: return .microphone - - case 4: return .bluetooth - - case 5: return .nfc - - case 6: return .location - - case 7: return .clipboard - - case 8: return .openUrl - - case 9: return .biometrics - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostDevicePermissionRequest, into buf: inout [UInt8]) { - switch value { - - - case .notifications: - writeInt(&buf, Int32(1)) - - - case .camera: - writeInt(&buf, Int32(2)) - - - case .microphone: - writeInt(&buf, Int32(3)) - - - case .bluetooth: - writeInt(&buf, Int32(4)) - - - case .nfc: - writeInt(&buf, Int32(5)) - - - case .location: - writeInt(&buf, Int32(6)) - - - case .clipboard: - writeInt(&buf, Int32(7)) - - - case .openUrl: - writeInt(&buf, Int32(8)) - - - case .biometrics: - writeInt(&buf, Int32(9)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostDevicePermissionRequest_lift(_ buf: RustBuffer) throws -> HostDevicePermissionRequest { - return try FfiConverterTypeHostDevicePermissionRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostDevicePermissionRequest_lower(_ value: HostDevicePermissionRequest) -> RustBuffer { - return FfiConverterTypeHostDevicePermissionRequest.lower(value) -} - - - -/** - * Request to query whether a feature is supported by the host. - */ - -public enum HostFeatureSupportedRequest: Equatable, Hashable { - - /** - * Ask whether the host can interact with the chain identified by genesis hash. - */ - case chain( - /** - * Chain genesis hash. - */genesisHash: Data - ) - - - - - -} - -#if compiler(>=6) -extension HostFeatureSupportedRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostFeatureSupportedRequest: FfiConverterRustBuffer { - typealias SwiftType = HostFeatureSupportedRequest - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostFeatureSupportedRequest { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .chain(genesisHash: try FfiConverterData.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostFeatureSupportedRequest, into buf: inout [UInt8]) { - switch value { - - - case let .chain(genesisHash): - writeInt(&buf, Int32(1)) - FfiConverterData.write(genesisHash, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostFeatureSupportedRequest_lift(_ buf: RustBuffer) throws -> HostFeatureSupportedRequest { - return try FfiConverterTypeHostFeatureSupportedRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostFeatureSupportedRequest_lower(_ value: HostFeatureSupportedRequest) -> RustBuffer { - return FfiConverterTypeHostFeatureSupportedRequest.lower(value) -} - - - -/** - * Local storage operation error. - */ - -public enum HostLocalStorageReadError: Equatable, Hashable { - - /** - * Storage quota exceeded. - */ - case full - /** - * Catch-all. - */ - case unknown( - /** - * Human-readable failure reason. - */reason: String - ) - - - - - -} - -#if compiler(>=6) -extension HostLocalStorageReadError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostLocalStorageReadError: FfiConverterRustBuffer { - typealias SwiftType = HostLocalStorageReadError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostLocalStorageReadError { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .full - - case 2: return .unknown(reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostLocalStorageReadError, into buf: inout [UInt8]) { - switch value { - - - case .full: - writeInt(&buf, Int32(1)) - - - case let .unknown(reason): - writeInt(&buf, Int32(2)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostLocalStorageReadError_lift(_ buf: RustBuffer) throws -> HostLocalStorageReadError { - return try FfiConverterTypeHostLocalStorageReadError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostLocalStorageReadError_lower(_ value: HostLocalStorageReadError) -> RustBuffer { - return FfiConverterTypeHostLocalStorageReadError.lower(value) -} - - - -/** - * Error from [`crate::api::System::navigate_to`]. - */ - -public enum HostNavigateToError: Equatable, Hashable { - - /** - * The target host is not authorized for outbound access: the user answered - * no to the prompt, a stored decision already refused it, or no prompt - * could be put to the user. - */ - case permissionDenied - /** - * Catch-all. - */ - case unknown( - /** - * Human-readable failure reason. - */reason: String - ) - - - - - -} - -#if compiler(>=6) -extension HostNavigateToError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostNavigateToError: FfiConverterRustBuffer { - typealias SwiftType = HostNavigateToError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostNavigateToError { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .permissionDenied - - case 2: return .unknown(reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostNavigateToError, into buf: inout [UInt8]) { - switch value { - - - case .permissionDenied: - writeInt(&buf, Int32(1)) - - - case let .unknown(reason): - writeInt(&buf, Int32(2)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostNavigateToError_lift(_ buf: RustBuffer) throws -> HostNavigateToError { - return try FfiConverterTypeHostNavigateToError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostNavigateToError_lower(_ value: HostNavigateToError) -> RustBuffer { - return FfiConverterTypeHostNavigateToError.lower(value) -} - - - -/** - * Platform category a host runs on. - */ - -public enum HostPlatform: Equatable, Hashable { - - /** - * Browser-embedded product (an iframe inside a web host). - */ - case web - /** - * Android application. - */ - case android - /** - * iOS application. - */ - case ios - /** - * Desktop application. - */ - case desktop - /** - * Command-line host running in a terminal or headless environment. - */ - case cli - /** - * Host could not classify its platform. - */ - case unknown - - - - - -} - -#if compiler(>=6) -extension HostPlatform: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostPlatform: FfiConverterRustBuffer { - typealias SwiftType = HostPlatform - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostPlatform { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .web - - case 2: return .android - - case 3: return .ios - - case 4: return .desktop - - case 5: return .cli - - case 6: return .unknown - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostPlatform, into buf: inout [UInt8]) { - switch value { - - - case .web: - writeInt(&buf, Int32(1)) - - - case .android: - writeInt(&buf, Int32(2)) - - - case .ios: - writeInt(&buf, Int32(3)) - - - case .desktop: - writeInt(&buf, Int32(4)) - - - case .cli: - writeInt(&buf, Int32(5)) - - - case .unknown: - writeInt(&buf, Int32(6)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostPlatform_lift(_ buf: RustBuffer) throws -> HostPlatform { - return try FfiConverterTypeHostPlatform.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostPlatform_lower(_ value: HostPlatform) -> RustBuffer { - return FfiConverterTypeHostPlatform.lower(value) -} - - - -/** - * Layout and styling modifiers applied to custom renderer components. - */ - -public enum Modifier: Equatable, Hashable { - - /** - * Outer spacing. - */ - case margin(Dimensions - ) - /** - * Inner spacing. - */ - case padding(Dimensions - ) - /** - * Background fill. - */ - case background(Background - ) - /** - * Border style. - */ - case border(BorderStyle - ) - /** - * Fixed height. - */ - case height( - /** - * Fixed height. - */height: Size - ) - /** - * Fixed width. - */ - case width( - /** - * Fixed width. - */width: Size - ) - /** - * Minimum width. - */ - case minWidth( - /** - * Minimum width. - */width: Size - ) - /** - * Minimum height. - */ - case minHeight( - /** - * Minimum height. - */height: Size - ) - /** - * Fill available width. - */ - case fillWidth( - /** - * Whether width should fill available space. - */enabled: Bool - ) - /** - * Fill available height. - */ - case fillHeight( - /** - * Whether height should fill available space. - */enabled: Bool - ) - - - - - -} - -#if compiler(>=6) -extension Modifier: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeModifier: FfiConverterRustBuffer { - typealias SwiftType = Modifier - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Modifier { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .margin(try FfiConverterTypeDimensions.read(from: &buf) - ) - - case 2: return .padding(try FfiConverterTypeDimensions.read(from: &buf) - ) - - case 3: return .background(try FfiConverterTypeBackground.read(from: &buf) - ) - - case 4: return .border(try FfiConverterTypeBorderStyle.read(from: &buf) - ) - - case 5: return .height(height: try FfiConverterTypeSize.read(from: &buf) - ) - - case 6: return .width(width: try FfiConverterTypeSize.read(from: &buf) - ) - - case 7: return .minWidth(width: try FfiConverterTypeSize.read(from: &buf) - ) - - case 8: return .minHeight(height: try FfiConverterTypeSize.read(from: &buf) - ) - - case 9: return .fillWidth(enabled: try FfiConverterBool.read(from: &buf) - ) - - case 10: return .fillHeight(enabled: try FfiConverterBool.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: Modifier, into buf: inout [UInt8]) { - switch value { - - - case let .margin(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeDimensions.write(v1, into: &buf) - - - case let .padding(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeDimensions.write(v1, into: &buf) - - - case let .background(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeBackground.write(v1, into: &buf) - - - case let .border(v1): - writeInt(&buf, Int32(4)) - FfiConverterTypeBorderStyle.write(v1, into: &buf) - - - case let .height(height): - writeInt(&buf, Int32(5)) - FfiConverterTypeSize.write(height, into: &buf) - - - case let .width(width): - writeInt(&buf, Int32(6)) - FfiConverterTypeSize.write(width, into: &buf) - - - case let .minWidth(width): - writeInt(&buf, Int32(7)) - FfiConverterTypeSize.write(width, into: &buf) - - - case let .minHeight(height): - writeInt(&buf, Int32(8)) - FfiConverterTypeSize.write(height, into: &buf) - - - case let .fillWidth(enabled): - writeInt(&buf, Int32(9)) - FfiConverterBool.write(enabled, into: &buf) - - - case let .fillHeight(enabled): - writeInt(&buf, Int32(10)) - FfiConverterBool.write(enabled, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeModifier_lift(_ buf: RustBuffer) throws -> Modifier { - return try FfiConverterTypeModifier.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeModifier_lower(_ value: Modifier) -> RustBuffer { - return FfiConverterTypeModifier.lower(value) -} - - - -/** - * Raw data to sign -- either binary bytes or a string message. - */ - -public enum RawPayload: Equatable, Hashable { - - /** - * Raw binary data to sign. - */ - case bytes( - /** - * Raw binary payload bytes. - */bytes: Data - ) - /** - * String message to sign. - */ - case payload( - /** - * String payload to sign. - */payload: String - ) - - - - - -} - -#if compiler(>=6) -extension RawPayload: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRawPayload: FfiConverterRustBuffer { - typealias SwiftType = RawPayload - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RawPayload { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .bytes(bytes: try FfiConverterData.read(from: &buf) - ) - - case 2: return .payload(payload: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: RawPayload, into buf: inout [UInt8]) { - switch value { - - - case let .bytes(bytes): - writeInt(&buf, Int32(1)) - FfiConverterData.write(bytes, into: &buf) - - - case let .payload(payload): - writeInt(&buf, Int32(2)) - FfiConverterString.write(payload, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRawPayload_lift(_ buf: RustBuffer) throws -> RawPayload { - return try FfiConverterTypeRawPayload.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRawPayload_lower(_ value: RawPayload) -> RustBuffer { - return FfiConverterTypeRawPayload.lower(value) -} - - - -/** - * One remote-operation permission requested by the product (RFC 0002). - * - * `ChainSubmit`, `PreimageSubmit`, and `StatementSubmit` are also triggered - * implicitly by the corresponding business calls when not yet granted. - */ - -public enum RemotePermission: Equatable, Hashable { - - /** - * Reaching a set of domains: outbound HTTP/WebSocket access, and sending - * the user out to one of them with `navigate_to`. - * - * One grant per host covers both, because both hand the same third party - * the same thing: that the user is here, and whatever the product puts in - * the URL. Splitting them would put the same question to the user twice. - */ - case remote( - /** - * Domain patterns requested by the product. Each is an exact host, a - * single-level wildcard (`*.example.com`), or `*` for any host. - */domains: [String] - ) - /** - * WebRTC access. - * - * Enforced inside the product's own realm rather than at a network layer: - * ICE reaches an arbitrary host over UDP, so no content rule list, request - * interceptor, or CSP directive observes it. A host peeks this decision - * before the product realm exists and the lockdown container removes - * `RTCPeerConnection` — and its vendor-prefixed aliases — unless the answer - * was an explicit grant. Resolving it up front is what makes the gate - * unforgeable, and it means a fresh grant applies from the next load. - * - * Camera and microphone capture is gated by the OS permission prompts and - * [`HostDevicePermissionRequest`], not by this permission. - */ - case webRtc - /** - * Submitting transactions on behalf of the user via `remote_chain_transaction_broadcast`. - */ - case chainSubmit - /** - * Submitting preimages on behalf of the user via `remote_preimage_submit`. - */ - case preimageSubmit - /** - * Submitting statements on behalf of the user via `remote_statement_store_submit`. - */ - case statementSubmit - - - - - -} - -#if compiler(>=6) -extension RemotePermission: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRemotePermission: FfiConverterRustBuffer { - typealias SwiftType = RemotePermission - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RemotePermission { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .remote(domains: try FfiConverterSequenceString.read(from: &buf) - ) - - case 2: return .webRtc - - case 3: return .chainSubmit - - case 4: return .preimageSubmit - - case 5: return .statementSubmit - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: RemotePermission, into buf: inout [UInt8]) { - switch value { - - - case let .remote(domains): - writeInt(&buf, Int32(1)) - FfiConverterSequenceString.write(domains, into: &buf) - - - case .webRtc: - writeInt(&buf, Int32(2)) - - - case .chainSubmit: - writeInt(&buf, Int32(3)) - - - case .preimageSubmit: - writeInt(&buf, Int32(4)) - - - case .statementSubmit: - writeInt(&buf, Int32(5)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRemotePermission_lift(_ buf: RustBuffer) throws -> RemotePermission { - return try FfiConverterTypeRemotePermission.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRemotePermission_lower(_ value: RemotePermission) -> RustBuffer { - return FfiConverterTypeRemotePermission.lower(value) -} - - - -/** - * A single step in a [`RingLocation`] path, addressing a ring within a chain. - */ - -public enum RingLocationJunction: Equatable, Hashable { - - /** - * Pallet instance hosting the ring collection. - */ - case palletInstance(UInt8 - ) - /** - * Ring collection identifier within the pallet. - */ - case collectionId(Data - ) - - - - - -} - -#if compiler(>=6) -extension RingLocationJunction: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeRingLocationJunction: FfiConverterRustBuffer { - typealias SwiftType = RingLocationJunction - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RingLocationJunction { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .palletInstance(try FfiConverterUInt8.read(from: &buf) - ) - - case 2: return .collectionId(try FfiConverterData.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: RingLocationJunction, into buf: inout [UInt8]) { - switch value { - - - case let .palletInstance(v1): - writeInt(&buf, Int32(1)) - FfiConverterUInt8.write(v1, into: &buf) - - - case let .collectionId(v1): - writeInt(&buf, Int32(2)) - FfiConverterData.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRingLocationJunction_lift(_ buf: RustBuffer) throws -> RingLocationJunction { - return try FfiConverterTypeRingLocationJunction.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeRingLocationJunction_lower(_ value: RingLocationJunction) -> RustBuffer { - return FfiConverterTypeRingLocationJunction.lower(value) -} - - - -/** - * Shape for borders and backgrounds. - */ - -public enum Shape: Equatable, Hashable { - - /** - * Border radius value. - */ - case rounded( - /** - * Border radius. - */radius: Size - ) - /** - * Circular shape. - */ - case circle - - - - - -} - -#if compiler(>=6) -extension Shape: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeShape: FfiConverterRustBuffer { - typealias SwiftType = Shape - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Shape { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .rounded(radius: try FfiConverterTypeSize.read(from: &buf) - ) - - case 2: return .circle - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: Shape, into buf: inout [UInt8]) { - switch value { - - - case let .rounded(radius): - writeInt(&buf, Int32(1)) - FfiConverterTypeSize.write(radius, into: &buf) - - - case .circle: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeShape_lift(_ buf: RustBuffer) throws -> Shape { - return try FfiConverterTypeShape.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeShape_lower(_ value: Shape) -> RustBuffer { - return FfiConverterTypeShape.lower(value) -} - - - -/** - * Identifies a named theme. - */ - -public enum ThemeName: Equatable, Hashable { - - /** - * A custom named theme. - */ - case custom(String - ) - /** - * The host's default theme. - */ - case `default` - - - - - -} - -#if compiler(>=6) -extension ThemeName: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeThemeName: FfiConverterRustBuffer { - typealias SwiftType = ThemeName - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ThemeName { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .custom(try FfiConverterString.read(from: &buf) - ) - - case 2: return .`default` - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ThemeName, into buf: inout [UInt8]) { - switch value { - - - case let .custom(v1): - writeInt(&buf, Int32(1)) - FfiConverterString.write(v1, into: &buf) - - - case .`default`: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeThemeName_lift(_ buf: RustBuffer) throws -> ThemeName { - return try FfiConverterTypeThemeName.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeThemeName_lower(_ value: ThemeName) -> RustBuffer { - return FfiConverterTypeThemeName.lower(value) -} - - - -/** - * Light or dark variant. - */ - -public enum ThemeVariant: Equatable, Hashable { - - /** - * Light appearance. - */ - case light - /** - * Dark appearance. - */ - case dark - - - - - -} - -#if compiler(>=6) -extension ThemeVariant: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeThemeVariant: FfiConverterRustBuffer { - typealias SwiftType = ThemeVariant - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ThemeVariant { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .light - - case 2: return .dark - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ThemeVariant, into buf: inout [UInt8]) { - switch value { - - - case .light: - writeInt(&buf, Int32(1)) - - - case .dark: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeThemeVariant_lift(_ buf: RustBuffer) throws -> ThemeVariant { - return try FfiConverterTypeThemeVariant.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeThemeVariant_lower(_ value: ThemeVariant) -> RustBuffer { - return FfiConverterTypeThemeVariant.lower(value) -} - - - -/** - * Text typography presets. - */ - -public enum TypographyStyle: Equatable, Hashable { - - /** - * Large headline text. - */ - case headlineLarge - /** - * Medium title text, regular weight. - */ - case titleMediumRegular - /** - * Large body text, regular weight. - */ - case bodyLargeRegular - /** - * Medium body text, regular weight. - */ - case bodyMediumRegular - /** - * Small body text, regular weight. - */ - case bodySmallRegular - - - - - -} - -#if compiler(>=6) -extension TypographyStyle: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTypographyStyle: FfiConverterRustBuffer { - typealias SwiftType = TypographyStyle - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TypographyStyle { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .headlineLarge - - case 2: return .titleMediumRegular - - case 3: return .bodyLargeRegular - - case 4: return .bodyMediumRegular - - case 5: return .bodySmallRegular - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TypographyStyle, into buf: inout [UInt8]) { - switch value { - - - case .headlineLarge: - writeInt(&buf, Int32(1)) - - - case .titleMediumRegular: - writeInt(&buf, Int32(2)) - - - case .bodyLargeRegular: - writeInt(&buf, Int32(3)) - - - case .bodyMediumRegular: - writeInt(&buf, Int32(4)) - - - case .bodySmallRegular: - writeInt(&buf, Int32(5)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTypographyStyle_lift(_ buf: RustBuffer) throws -> TypographyStyle { - return try FfiConverterTypeTypographyStyle.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTypographyStyle_lower(_ value: TypographyStyle) -> RustBuffer { - return FfiConverterTypeTypographyStyle.lower(value) -} - - - -/** - * Vertical alignment options. - */ - -public enum VerticalAlignment: Equatable, Hashable { - - /** - * Align to the top. - */ - case top - /** - * Center vertically. - */ - case center - /** - * Align to the bottom. - */ - case bottom - - - - - -} - -#if compiler(>=6) -extension VerticalAlignment: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeVerticalAlignment: FfiConverterRustBuffer { - typealias SwiftType = VerticalAlignment - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VerticalAlignment { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .top - - case 2: return .center - - case 3: return .bottom - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: VerticalAlignment, into buf: inout [UInt8]) { - switch value { - - - case .top: - writeInt(&buf, Int32(1)) - - - case .center: - writeInt(&buf, Int32(2)) - - - case .bottom: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVerticalAlignment_lift(_ buf: RustBuffer) throws -> VerticalAlignment { - return try FfiConverterTypeVerticalAlignment.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVerticalAlignment_lower(_ value: VerticalAlignment) -> RustBuffer { - return FfiConverterTypeVerticalAlignment.lower(value) -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { - typealias SwiftType = UInt32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt32.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterUInt32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer { - typealias SwiftType = UInt64? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt64.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterUInt64.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer { - typealias SwiftType = Bool? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterBool.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterBool.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { - typealias SwiftType = String? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterString.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterString.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { - typealias SwiftType = Data? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterData.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterData.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeArrangement: FfiConverterRustBuffer { - typealias SwiftType = Arrangement? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeArrangement.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeArrangement.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeButtonVariant: FfiConverterRustBuffer { - typealias SwiftType = ButtonVariant? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeButtonVariant.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeButtonVariant.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeColorToken: FfiConverterRustBuffer { - typealias SwiftType = ColorToken? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeColorToken.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeColorToken.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeContentAlignment: FfiConverterRustBuffer { - typealias SwiftType = ContentAlignment? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeContentAlignment.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeContentAlignment.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeHorizontalAlignment: FfiConverterRustBuffer { - typealias SwiftType = HorizontalAlignment? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeHorizontalAlignment.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeHorizontalAlignment.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeShape: FfiConverterRustBuffer { - typealias SwiftType = Shape? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeShape.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeShape.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeTypographyStyle: FfiConverterRustBuffer { - typealias SwiftType = TypographyStyle? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeTypographyStyle.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeTypographyStyle.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeVerticalAlignment: FfiConverterRustBuffer { - typealias SwiftType = VerticalAlignment? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeVerticalAlignment.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeVerticalAlignment.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeSize: FfiConverterRustBuffer { - typealias SwiftType = Size? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeSize.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeSize.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { - typealias SwiftType = [String] - - public static func write(_ value: [String], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterString.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] { - let len: Int32 = try readInt(&buf) - var seq = [String]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterString.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeChatAction: FfiConverterRustBuffer { - typealias SwiftType = [ChatAction] - - public static func write(_ value: [ChatAction], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeChatAction.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChatAction] { - let len: Int32 = try readInt(&buf) - var seq = [ChatAction]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeChatAction.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeChatMedia: FfiConverterRustBuffer { - typealias SwiftType = [ChatMedia] - - public static func write(_ value: [ChatMedia], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeChatMedia.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChatMedia] { - let len: Int32 = try readInt(&buf) - var seq = [ChatMedia]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeChatMedia.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeTxPayloadExtension: FfiConverterRustBuffer { - typealias SwiftType = [TxPayloadExtension] - - public static func write(_ value: [TxPayloadExtension], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeTxPayloadExtension.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxPayloadExtension] { - let len: Int32 = try readInt(&buf) - var seq = [TxPayloadExtension]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxPayloadExtension.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeVrfTranscriptItem: FfiConverterRustBuffer { - typealias SwiftType = [VrfTranscriptItem] - - public static func write(_ value: [VrfTranscriptItem], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeVrfTranscriptItem.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [VrfTranscriptItem] { - let len: Int32 = try readInt(&buf) - var seq = [VrfTranscriptItem]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeVrfTranscriptItem.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeCustomRendererNode: FfiConverterRustBuffer { - typealias SwiftType = [CustomRendererNode] - - public static func write(_ value: [CustomRendererNode], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeCustomRendererNode.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CustomRendererNode] { - let len: Int32 = try readInt(&buf) - var seq = [CustomRendererNode]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeCustomRendererNode.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeModifier: FfiConverterRustBuffer { - typealias SwiftType = [Modifier] - - public static func write(_ value: [Modifier], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeModifier.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Modifier] { - let len: Int32 = try readInt(&buf) - var seq = [Modifier]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeModifier.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeRingLocationJunction: FfiConverterRustBuffer { - typealias SwiftType = [RingLocationJunction] - - public static func write(_ value: [RingLocationJunction], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeRingLocationJunction.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RingLocationJunction] { - let len: Int32 = try readInt(&buf) - var seq = [RingLocationJunction]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeRingLocationJunction.read(from: &buf)) - } - return seq - } -} - - -public typealias Bytes32 = Data - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeBytes32: FfiConverter { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bytes32 { - return try FfiConverterData.read(from: &buf) - } - - public static func write(_ value: Bytes32, into buf: inout [UInt8]) { - return FfiConverterData.write(value, into: &buf) - } - - public static func lift(_ value: RustBuffer) throws -> Bytes32 { - return try FfiConverterData.lift(value) - } - - public static func lower(_ value: Bytes32) -> RustBuffer { - return FfiConverterData.lower(value) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBytes32_lift(_ value: RustBuffer) throws -> Bytes32 { - return try FfiConverterTypeBytes32.lift(value) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBytes32_lower(_ value: Bytes32) -> RustBuffer { - return FfiConverterTypeBytes32.lower(value) -} - - - -public typealias OptionalBool = Bool? - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeOptionalBool: FfiConverter { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OptionalBool { - return try FfiConverterOptionBool.read(from: &buf) - } - - public static func write(_ value: OptionalBool, into buf: inout [UInt8]) { - return FfiConverterOptionBool.write(value, into: &buf) - } - - public static func lift(_ value: RustBuffer) throws -> OptionalBool { - return try FfiConverterOptionBool.lift(value) - } - - public static func lower(_ value: OptionalBool) -> RustBuffer { - return FfiConverterOptionBool.lower(value) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeOptionalBool_lift(_ value: RustBuffer) throws -> OptionalBool { - return try FfiConverterTypeOptionalBool.lift(value) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeOptionalBool_lower(_ value: OptionalBool) -> RustBuffer { - return FfiConverterTypeOptionalBool.lower(value) -} - - - -public typealias Size = UInt64 - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSize: FfiConverter { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Size { - return try FfiConverterUInt64.read(from: &buf) - } - - public static func write(_ value: Size, into buf: inout [UInt8]) { - return FfiConverterUInt64.write(value, into: &buf) - } - - public static func lift(_ value: UInt64) throws -> Size { - return try FfiConverterUInt64.lift(value) - } - - public static func lower(_ value: Size) -> UInt64 { - return FfiConverterUInt64.lower(value) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSize_lift(_ value: UInt64) throws -> Size { - return try FfiConverterTypeSize.lift(value) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSize_lower(_ value: Size) -> UInt64 { - return FfiConverterTypeSize.lower(value) -} - - -private enum InitializationResult { - case ok - case contractVersionMismatch - case apiChecksumMismatch -} -// Use a global variable to perform the versioning checks. Swift ensures that -// the code inside is only computed once. -private let initializationResult: InitializationResult = { - // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 30 - // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_truapi_uniffi_contract_version() - if bindings_contract_version != scaffolding_contract_version { - return InitializationResult.contractVersionMismatch - } - - return InitializationResult.ok -}() - -// Make the ensure init function public so that other modules which have external type references to -// our types can call it. -public func uniffiEnsureTruapiInitialized() { - switch initializationResult { - case .ok: - break - case .contractVersionMismatch: - fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") - case .apiChecksumMismatch: - fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } -} - -// swiftlint:enable all \ No newline at end of file diff --git a/ios/truapi-host/Sources/TrUAPIHost/truapi_platform.swift b/ios/truapi-host/Sources/TrUAPIHost/truapi_platform.swift deleted file mode 100644 index 01783da40..000000000 --- a/ios/truapi-host/Sources/TrUAPIHost/truapi_platform.swift +++ /dev/null @@ -1,2631 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -// swiftlint:disable all -import Foundation - -// Depending on the consumer's build setup, the low-level FFI code -// might be in a separate module, or it might be compiled inline into -// this module. This is a bit of light hackery to work with both. -#if canImport(truapi_platformFFI) -import truapi_platformFFI -#endif - -fileprivate extension RustBuffer { - // Allocate a new buffer, copying the contents of a `UInt8` array. - init(bytes: [UInt8]) { - let rbuf = bytes.withUnsafeBufferPointer { ptr in - RustBuffer.from(ptr) - } - self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) - } - - static func empty() -> RustBuffer { - RustBuffer(capacity: 0, len:0, data: nil) - } - - static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_truapi_platform_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } - } - - // Frees the buffer in place. - // The buffer must not be used after this is called. - func deallocate() { - try! rustCall { ffi_truapi_platform_rustbuffer_free(self, $0) } - } -} - -fileprivate extension ForeignBytes { - init(bufferPointer: UnsafeBufferPointer) { - 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(_ 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 -// lifting and lowering that type from C-compatible data, and for reading and writing -// values of that type in a buffer. - -// Helper classes/extensions that don't change. -// Someday, this will be in a library of its own. - -fileprivate extension Data { - init(rustBuffer: RustBuffer) { - self.init( - bytesNoCopy: rustBuffer.data!, - count: Int(rustBuffer.len), - deallocator: .none - ) - } -} - -// Define reader functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. -// -// With external types, one swift source file needs to be able to call the read -// method on another source file's FfiConverter, but then what visibility -// should Reader have? -// - If Reader is fileprivate, then this means the read() must also -// be fileprivate, which doesn't work with external types. -// - If Reader is internal/public, we'll get compile errors since both source -// files will try define the same type. -// -// Instead, the read() method and these helper functions input a tuple of data - -fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { - (data: data, offset: 0) -} - -// Reads an integer at the current offset, in big-endian order, and advances -// the offset on success. Throws if reading the integer would move the -// offset past the end of the buffer. -fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset...size - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - if T.self == UInt8.self { - let value = reader.data[reader.offset] - reader.offset += 1 - return value as! T - } - var value: T = 0 - let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) - reader.offset = range.upperBound - return value.bigEndian -} - -// Reads an arbitrary number of bytes, to be used to read -// raw bytes, this is useful when lifting strings -fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { - let range = reader.offset..<(reader.offset+count) - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - var value = [UInt8](repeating: 0, count: count) - value.withUnsafeMutableBufferPointer({ buffer in - reader.data.copyBytes(to: buffer, from: range) - }) - reader.offset = range.upperBound - return value -} - -// Reads a float at the current offset. -fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return Float(bitPattern: try readInt(&reader)) -} - -// Reads a float at the current offset. -fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return Double(bitPattern: try readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { - return reader.offset < reader.data.count -} - -// Define writer functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. See the above discussion on Readers for details. - -fileprivate func createWriter() -> [UInt8] { - return [] -} - -fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { - writer.append(contentsOf: byteArr) -} - -// Writes an integer in big-endian order. -// -// Warning: make sure what you are trying to write -// is in the correct type! -fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous to the Rust trait of the same name. -fileprivate protocol FfiConverter { - associatedtype FfiType - associatedtype SwiftType - - static func lift(_ value: FfiType) throws -> SwiftType - static func lower(_ value: SwiftType) -> FfiType - static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType - static func write(_ value: SwiftType, into buf: inout [UInt8]) -} - -// Types conforming to `Primitive` pass themselves directly over the FFI. -fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } - -extension FfiConverterPrimitive { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> FfiType { - return value - } -} - -// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. -// Used for complex types where it's hard to write a custom lift/lower. -fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ buf: RustBuffer) throws -> SwiftType { - var reader = createReader(data: Data(rustBuffer: buf)) - let value = try read(from: &reader) - if hasRemaining(reader) { - throw UniffiInternalError.incompleteData - } - buf.deallocate() - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> RustBuffer { - var writer = createWriter() - write(value, into: &writer) - return RustBuffer(bytes: writer) - } -} -// An error type for FFI errors. These errors occur at the UniFFI level, not -// the library level. -fileprivate enum UniffiInternalError: LocalizedError { - case bufferOverflow - case incompleteData - case unexpectedOptionalTag - case unexpectedEnumCase - case unexpectedNullPointer - case unexpectedRustCallStatusCode - case unexpectedRustCallError - case unexpectedStaleHandle - case rustPanic(_ message: String) - - public var errorDescription: String? { - switch self { - case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" - case .incompleteData: return "The buffer still has data after lifting its containing value" - case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" - case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" - case .unexpectedNullPointer: return "Raw pointer value was null" - case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" - case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" - case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" - case let .rustPanic(message): return message - } - } -} - -fileprivate extension NSLock { - func withLock(f: () throws -> T) rethrows -> T { - self.lock() - defer { self.unlock() } - return try f() - } -} - -fileprivate let CALL_SUCCESS: Int8 = 0 -fileprivate let CALL_ERROR: Int8 = 1 -fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 -fileprivate let CALL_CANCELLED: Int8 = 3 - -fileprivate extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer.init( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - let neverThrow: ((RustBuffer) throws -> Never)? = nil - return try makeRustCall(callback, errorHandler: neverThrow) -} - -private func rustCallWithError( - _ errorHandler: @escaping (RustBuffer) throws -> E, - _ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: errorHandler) -} - -private func makeRustCall( - _ callback: (UnsafeMutablePointer) -> T, - errorHandler: ((RustBuffer) throws -> E)? -) throws -> T { - uniffiEnsureTruapiPlatformInitialized() - var callStatus = RustCallStatus.init() - let returnedVal = callback(&callStatus) - try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) - return returnedVal -} - -private func uniffiCheckCallStatus( - callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> E)? -) throws { - switch callStatus.code { - case CALL_SUCCESS: - return - - case CALL_ERROR: - if let errorHandler = errorHandler { - throw try errorHandler(callStatus.errorBuf) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.unexpectedRustCallError - } - - case CALL_UNEXPECTED_ERROR: - // When the rust code sees a panic, it tries to construct a RustBuffer - // with the message. But if that code panics, then it just sends back - // an empty buffer. - if callStatus.errorBuf.len > 0 { - throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - case CALL_CANCELLED: - fatalError("Cancellation not supported yet") - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -private func uniffiTraitInterfaceCall( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> () -) { - do { - try writeReturn(makeCall()) - } catch let error { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) - } -} - -private func uniffiTraitInterfaceCallWithError( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> (), - lowerError: (E) -> RustBuffer -) { - do { - try writeReturn(makeCall()) - } catch let error as E { - callStatus.pointee.code = CALL_ERROR - callStatus.pointee.errorBuf = lowerError(error) - } catch { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - 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: @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 = UNIFFI_HANDLEMAP_INITIAL - - func insert(obj: T) -> UInt64 { - lock.withLock { - 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 { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - 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 { - guard let obj = map.removeValue(forKey: handle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - var count: Int { - get { - map.count - } - } -} - - -// Public interface members begin here. - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { - typealias FfiType = UInt64 - typealias SwiftType = UInt64 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterString: FfiConverter { - typealias SwiftType = String - typealias FfiType = RustBuffer - - public static func lift(_ value: RustBuffer) throws -> String { - defer { - value.deallocate() - } - if value.data == nil { - return String() - } - let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) - // 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 { - return value.utf8CString.withUnsafeBufferPointer { ptr in - // The swift string gives us int8_t, we want uint8_t. - ptr.withMemoryRebound(to: UInt8.self) { ptr in - // The swift string gives us a trailing null byte, we don't want it. - let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) - return RustBuffer.from(buf) - } - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { - let len: Int32 = try readInt(&buf) - // 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]) { - let len = Int32(value.utf8.count) - writeInt(&buf, len) - writeBytes(&buf, value.utf8) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterData: FfiConverterRustBuffer { - typealias SwiftType = Data - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { - let len: Int32 = try readInt(&buf) - return Data(try readBytes(&buf, count: Int(len))) - } - - public static func write(_ value: Data, into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - writeBytes(&buf, value) - } -} - - -/** - * Review shown before a product asks to access another product account. - */ -public struct AccountAccessReview: Equatable, Hashable { - /** - * Product currently handling the request. - */ - public var requestingProductId: String - /** - * Product whose account is being requested. - */ - public var targetProductId: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product currently handling the request. - */requestingProductId: String, - /** - * Product whose account is being requested. - */targetProductId: String) { - self.requestingProductId = requestingProductId - self.targetProductId = targetProductId - } - - - - -} - -#if compiler(>=6) -extension AccountAccessReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAccountAccessReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountAccessReview { - return - try AccountAccessReview( - requestingProductId: FfiConverterString.read(from: &buf), - targetProductId: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: AccountAccessReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.requestingProductId, into: &buf) - FfiConverterString.write(value.targetProductId, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountAccessReview_lift(_ buf: RustBuffer) throws -> AccountAccessReview { - return try FfiConverterTypeAccountAccessReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountAccessReview_lower(_ value: AccountAccessReview) -> RustBuffer { - return FfiConverterTypeAccountAccessReview.lower(value) -} - - -/** - * Review shown before a product derives a contextual alias (RFC 0004). - */ -public struct AccountAliasReview: Equatable, Hashable { - /** - * Product requesting the alias. - */ - public var callingProductId: String - /** - * Product-scoped context the alias is bound to. - */ - public var context: ProductProofContext - /** - * Ring the alias is derived against. - */ - public var ringLocation: RingLocation - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product requesting the alias. - */callingProductId: String, - /** - * Product-scoped context the alias is bound to. - */context: ProductProofContext, - /** - * Ring the alias is derived against. - */ringLocation: RingLocation) { - self.callingProductId = callingProductId - self.context = context - self.ringLocation = ringLocation - } - - - - -} - -#if compiler(>=6) -extension AccountAliasReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAccountAliasReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountAliasReview { - return - try AccountAliasReview( - callingProductId: FfiConverterString.read(from: &buf), - context: FfiConverterTypeProductProofContext.read(from: &buf), - ringLocation: FfiConverterTypeRingLocation.read(from: &buf) - ) - } - - public static func write(_ value: AccountAliasReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.callingProductId, into: &buf) - FfiConverterTypeProductProofContext.write(value.context, into: &buf) - FfiConverterTypeRingLocation.write(value.ringLocation, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountAliasReview_lift(_ buf: RustBuffer) throws -> AccountAliasReview { - return try FfiConverterTypeAccountAliasReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountAliasReview_lower(_ value: AccountAliasReview) -> RustBuffer { - return FfiConverterTypeAccountAliasReview.lower(value) -} - - -/** - * Review shown before a product creates a ring-VRF proof (RFC 0004). - */ -public struct CreateProofReview: Equatable, Hashable { - /** - * Product requesting the proof. - */ - public var callingProductId: String - /** - * Product-scoped context the proof's alias is bound to. - */ - public var context: ProductProofContext - /** - * Ring the proof is generated against. - */ - public var ringLocation: RingLocation - /** - * Opaque message bound into the proof. - */ - public var message: Data - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product requesting the proof. - */callingProductId: String, - /** - * Product-scoped context the proof's alias is bound to. - */context: ProductProofContext, - /** - * Ring the proof is generated against. - */ringLocation: RingLocation, - /** - * Opaque message bound into the proof. - */message: Data) { - self.callingProductId = callingProductId - self.context = context - self.ringLocation = ringLocation - self.message = message - } - - - - -} - -#if compiler(>=6) -extension CreateProofReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeCreateProofReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CreateProofReview { - return - try CreateProofReview( - callingProductId: FfiConverterString.read(from: &buf), - context: FfiConverterTypeProductProofContext.read(from: &buf), - ringLocation: FfiConverterTypeRingLocation.read(from: &buf), - message: FfiConverterData.read(from: &buf) - ) - } - - public static func write(_ value: CreateProofReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.callingProductId, into: &buf) - FfiConverterTypeProductProofContext.write(value.context, into: &buf) - FfiConverterTypeRingLocation.write(value.ringLocation, into: &buf) - FfiConverterData.write(value.message, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateProofReview_lift(_ buf: RustBuffer) throws -> CreateProofReview { - return try FfiConverterTypeCreateProofReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateProofReview_lower(_ value: CreateProofReview) -> RustBuffer { - return FfiConverterTypeCreateProofReview.lower(value) -} - - -/** - * One chain a host serves: a protocol chain role mapped to the concrete - * chain of the host's configured environment. - */ -public struct HostChainEntry: Equatable, Hashable { - /** - * Protocol role this entry answers for. - */ - public var identifier: ChainIdentifier - /** - * Genesis hash identifying the chain in all chain-scoped calls. - */ - public var genesisHash: Bytes32 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Protocol role this entry answers for. - */identifier: ChainIdentifier, - /** - * Genesis hash identifying the chain in all chain-scoped calls. - */genesisHash: Bytes32) { - self.identifier = identifier - self.genesisHash = genesisHash - } - - - - -} - -#if compiler(>=6) -extension HostChainEntry: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostChainEntry: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostChainEntry { - return - try HostChainEntry( - identifier: FfiConverterTypeChainIdentifier.read(from: &buf), - genesisHash: FfiConverterTypeBytes32.read(from: &buf) - ) - } - - public static func write(_ value: HostChainEntry, into buf: inout [UInt8]) { - FfiConverterTypeChainIdentifier.write(value.identifier, into: &buf) - FfiConverterTypeBytes32.write(value.genesisHash, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChainEntry_lift(_ buf: RustBuffer) throws -> HostChainEntry { - return try FfiConverterTypeHostChainEntry.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChainEntry_lower(_ value: HostChainEntry) -> RustBuffer { - return FfiConverterTypeHostChainEntry.lower(value) -} - - -/** - * The chain set a host serves: its environment plus one entry per chain role. - */ -public struct HostChainSet: Equatable, Hashable { - /** - * Ecosystem the host is configured for, e.g. "polkadot", "paseo". - */ - public var network: String - /** - * Chains this host serves, keyed by protocol role. - */ - public var chains: [HostChainEntry] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Ecosystem the host is configured for, e.g. "polkadot", "paseo". - */network: String, - /** - * Chains this host serves, keyed by protocol role. - */chains: [HostChainEntry]) { - self.network = network - self.chains = chains - } - - - - -} - -#if compiler(>=6) -extension HostChainSet: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostChainSet: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostChainSet { - return - try HostChainSet( - network: FfiConverterString.read(from: &buf), - chains: FfiConverterSequenceTypeHostChainEntry.read(from: &buf) - ) - } - - public static func write(_ value: HostChainSet, into buf: inout [UInt8]) { - FfiConverterString.write(value.network, into: &buf) - FfiConverterSequenceTypeHostChainEntry.write(value.chains, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChainSet_lift(_ buf: RustBuffer) throws -> HostChainSet { - return try FfiConverterTypeHostChainSet.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostChainSet_lower(_ value: HostChainSet) -> RustBuffer { - return FfiConverterTypeHostChainSet.lower(value) -} - - -/** - * Review shown before a product learns the user's primary identity. - */ -public struct IdentityDisclosureReview: Equatable, Hashable { - /** - * Product currently handling the request. - */ - public var productId: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product currently handling the request. - */productId: String) { - self.productId = productId - } - - - - -} - -#if compiler(>=6) -extension IdentityDisclosureReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeIdentityDisclosureReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IdentityDisclosureReview { - return - try IdentityDisclosureReview( - productId: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: IdentityDisclosureReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.productId, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeIdentityDisclosureReview_lift(_ buf: RustBuffer) throws -> IdentityDisclosureReview { - return try FfiConverterTypeIdentityDisclosureReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeIdentityDisclosureReview_lower(_ value: IdentityDisclosureReview) -> RustBuffer { - return FfiConverterTypeIdentityDisclosureReview.lower(value) -} - - -/** - * Review shown before a preimage is submitted. - */ -public struct PreimageSubmitReview: Equatable, Hashable { - /** - * Size of the preimage in bytes. - */ - public var size: UInt64 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Size of the preimage in bytes. - */size: UInt64) { - self.size = size - } - - - - -} - -#if compiler(>=6) -extension PreimageSubmitReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePreimageSubmitReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PreimageSubmitReview { - return - try PreimageSubmitReview( - size: FfiConverterUInt64.read(from: &buf) - ) - } - - public static func write(_ value: PreimageSubmitReview, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.size, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePreimageSubmitReview_lift(_ buf: RustBuffer) throws -> PreimageSubmitReview { - return try FfiConverterTypePreimageSubmitReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePreimageSubmitReview_lower(_ value: PreimageSubmitReview) -> RustBuffer { - return FfiConverterTypePreimageSubmitReview.lower(value) -} - - -/** - * Review shown before a product resolves its own account subtree over SSO, - * when the value is not cached and the core must ask the Account Holder. - */ -public struct ProductSubtreeReview: Equatable, Hashable { - /** - * Product resolving its own account. - */ - public var productId: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product resolving its own account. - */productId: String) { - self.productId = productId - } - - - - -} - -#if compiler(>=6) -extension ProductSubtreeReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductSubtreeReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductSubtreeReview { - return - try ProductSubtreeReview( - productId: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: ProductSubtreeReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.productId, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductSubtreeReview_lift(_ buf: RustBuffer) throws -> ProductSubtreeReview { - return try FfiConverterTypeProductSubtreeReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductSubtreeReview_lower(_ value: ProductSubtreeReview) -> RustBuffer { - return FfiConverterTypeProductSubtreeReview.lower(value) -} - - -/** - * Review shown before allocating resources for a product. Names the - * beneficiary product so the user knows which product receives the - * (signing-capable) allowance key they are approving. - */ -public struct ResourceAllocationReview: Equatable, Hashable { - /** - * Product the allocation is requested for. - */ - public var callingProductId: String - /** - * Resources to allocate. - */ - public var resources: [AllocatableResource] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product the allocation is requested for. - */callingProductId: String, - /** - * Resources to allocate. - */resources: [AllocatableResource]) { - self.callingProductId = callingProductId - self.resources = resources - } - - - - -} - -#if compiler(>=6) -extension ResourceAllocationReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeResourceAllocationReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourceAllocationReview { - return - try ResourceAllocationReview( - callingProductId: FfiConverterString.read(from: &buf), - resources: FfiConverterSequenceTypeAllocatableResource.read(from: &buf) - ) - } - - public static func write(_ value: ResourceAllocationReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.callingProductId, into: &buf) - FfiConverterSequenceTypeAllocatableResource.write(value.resources, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeResourceAllocationReview_lift(_ buf: RustBuffer) throws -> ResourceAllocationReview { - return try FfiConverterTypeResourceAllocationReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeResourceAllocationReview_lower(_ value: ResourceAllocationReview) -> RustBuffer { - return FfiConverterTypeResourceAllocationReview.lower(value) -} - - -/** - * Decoded session fields a host shell needs to render account UI without - * parsing the opaque session blob the core persists through [`CoreStorage`]. - */ -public struct SessionUiInfo: Equatable, Hashable { - /** - * 32-byte sr25519 root public key of the active session. - */ - public var publicKey: Bytes32 - /** - * Wallet identity account id used for the dotNS username lookup on Asset Hub. - */ - public var identityAccountId: Bytes32? - /** - * X25519 public key addressing this identity in chat. Public counterpart - * of the key [`CoreAdmin::get_session_chat_identity_key`] serves. - */ - public var chatPublicKey: Bytes32? - /** - * X25519 public key of the wallet device that answered pairing. Hosts - * running their own encrypted device-sync channel key it against this. - */ - public var deviceEncPublicKey: Bytes32? - /** - * Statement-store account id the paired wallet signs every session-channel - * statement with. Whether it is scoped to the wallet device or to the - * wallet identity is the wallet's choice, so hosts must not treat it as a - * device discriminator; use [`Self::device_enc_public_key`] for that. - */ - public var peerStatementAccountId: Bytes32? - /** - * Short username from the dotNS identity record on Asset Hub. - */ - public var liteUsername: String? - /** - * Fully qualified username from the dotNS identity record on Asset Hub. - */ - public var fullUsername: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * 32-byte sr25519 root public key of the active session. - */publicKey: Bytes32, - /** - * Wallet identity account id used for the dotNS username lookup on Asset Hub. - */identityAccountId: Bytes32?, - /** - * X25519 public key addressing this identity in chat. Public counterpart - * of the key [`CoreAdmin::get_session_chat_identity_key`] serves. - */chatPublicKey: Bytes32?, - /** - * X25519 public key of the wallet device that answered pairing. Hosts - * running their own encrypted device-sync channel key it against this. - */deviceEncPublicKey: Bytes32?, - /** - * Statement-store account id the paired wallet signs every session-channel - * statement with. Whether it is scoped to the wallet device or to the - * wallet identity is the wallet's choice, so hosts must not treat it as a - * device discriminator; use [`Self::device_enc_public_key`] for that. - */peerStatementAccountId: Bytes32?, - /** - * Short username from the dotNS identity record on Asset Hub. - */liteUsername: String?, - /** - * Fully qualified username from the dotNS identity record on Asset Hub. - */fullUsername: String?) { - self.publicKey = publicKey - self.identityAccountId = identityAccountId - self.chatPublicKey = chatPublicKey - self.deviceEncPublicKey = deviceEncPublicKey - self.peerStatementAccountId = peerStatementAccountId - self.liteUsername = liteUsername - self.fullUsername = fullUsername - } - - - - -} - -#if compiler(>=6) -extension SessionUiInfo: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSessionUiInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SessionUiInfo { - return - try SessionUiInfo( - publicKey: FfiConverterTypeBytes32.read(from: &buf), - identityAccountId: FfiConverterOptionTypeBytes32.read(from: &buf), - chatPublicKey: FfiConverterOptionTypeBytes32.read(from: &buf), - deviceEncPublicKey: FfiConverterOptionTypeBytes32.read(from: &buf), - peerStatementAccountId: FfiConverterOptionTypeBytes32.read(from: &buf), - liteUsername: FfiConverterOptionString.read(from: &buf), - fullUsername: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: SessionUiInfo, into buf: inout [UInt8]) { - FfiConverterTypeBytes32.write(value.publicKey, into: &buf) - FfiConverterOptionTypeBytes32.write(value.identityAccountId, into: &buf) - FfiConverterOptionTypeBytes32.write(value.chatPublicKey, into: &buf) - FfiConverterOptionTypeBytes32.write(value.deviceEncPublicKey, into: &buf) - FfiConverterOptionTypeBytes32.write(value.peerStatementAccountId, into: &buf) - FfiConverterOptionString.write(value.liteUsername, into: &buf) - FfiConverterOptionString.write(value.fullUsername, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSessionUiInfo_lift(_ buf: RustBuffer) throws -> SessionUiInfo { - return try FfiConverterTypeSessionUiInfo.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSessionUiInfo_lower(_ value: SessionUiInfo) -> RustBuffer { - return FfiConverterTypeSessionUiInfo.lower(value) -} - - -/** - * Review shown before signing an RFC-0023 VRF transcript. - */ -public struct SignVrfReview: Equatable, Hashable { - /** - * Product making the request. - */ - public var callingProductId: String - /** - * Product account and exact ordered transcript. - */ - public var request: HostAccountSignVrfRequest - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product making the request. - */callingProductId: String, - /** - * Product account and exact ordered transcript. - */request: HostAccountSignVrfRequest) { - self.callingProductId = callingProductId - self.request = request - } - - - - -} - -#if compiler(>=6) -extension SignVrfReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSignVrfReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignVrfReview { - return - try SignVrfReview( - callingProductId: FfiConverterString.read(from: &buf), - request: FfiConverterTypeHostAccountSignVrfRequest.read(from: &buf) - ) - } - - public static func write(_ value: SignVrfReview, into buf: inout [UInt8]) { - FfiConverterString.write(value.callingProductId, into: &buf) - FfiConverterTypeHostAccountSignVrfRequest.write(value.request, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignVrfReview_lift(_ buf: RustBuffer) throws -> SignVrfReview { - return try FfiConverterTypeSignVrfReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignVrfReview_lower(_ value: SignVrfReview) -> RustBuffer { - return FfiConverterTypeSignVrfReview.lower(value) -} - - -/** - * Review shown before a product account signs a Statement Store proof - * payload. Distinct from raw-message signing: the payload is the exact - * unsigned statement, signed as-is (no `` envelope), so the host must - * not present it with the raw-signing convention. - */ -public struct StatementStoreProductSignReview: Equatable, Hashable { - /** - * Product account that will sign the statement payload. - */ - public var account: ProductAccountId - /** - * Exact unsigned statement payload to be signed. - */ - public var payload: Data - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Product account that will sign the statement payload. - */account: ProductAccountId, - /** - * Exact unsigned statement payload to be signed. - */payload: Data) { - self.account = account - self.payload = payload - } - - - - -} - -#if compiler(>=6) -extension StatementStoreProductSignReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeStatementStoreProductSignReview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StatementStoreProductSignReview { - return - try StatementStoreProductSignReview( - account: FfiConverterTypeProductAccountId.read(from: &buf), - payload: FfiConverterData.read(from: &buf) - ) - } - - public static func write(_ value: StatementStoreProductSignReview, into buf: inout [UInt8]) { - FfiConverterTypeProductAccountId.write(value.account, into: &buf) - FfiConverterData.write(value.payload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementStoreProductSignReview_lift(_ buf: RustBuffer) throws -> StatementStoreProductSignReview { - return try FfiConverterTypeStatementStoreProductSignReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementStoreProductSignReview_lower(_ value: StatementStoreProductSignReview) -> RustBuffer { - return FfiConverterTypeStatementStoreProductSignReview.lower(value) -} - - -/** - * Auth/session lifecycle state the core projects for host UI. The core owns - * every transition and emits states in order; hosts render the current state - * and never derive auth UI from any other signal. - */ - -public enum AuthState: Equatable, Hashable { - - /** - * No active session and no login in progress. - */ - case disconnected - /** - * A login is in progress: present the pairing deeplink/QR. Leave this - * state only on a subsequent emission (connected, failed, or - * disconnected after cancellation). - */ - case pairing( - /** - * Wallet pairing deeplink to render as a QR code or open directly. - */deeplink: String - ) - /** - * A session is active. - */ - case connected(SessionUiInfo - ) - /** - * The last login attempt failed; show the reason and offer a retry. - */ - case loginFailed( - /** - * What kind of failure this was. Hosts branch on this and treat - * `reason` as display copy only. - */kind: LoginFailureKind, - /** - * Human-readable failure reason. - */reason: String - ) - /** - * The wallet accepted the pairing request and the core is resolving and - * persisting the session. Hosts should replace the pairing QR with an - * in-progress presentation until a terminal state is emitted. - */ - case authenticating - - - - - -} - -#if compiler(>=6) -extension AuthState: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAuthState: FfiConverterRustBuffer { - typealias SwiftType = AuthState - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AuthState { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .disconnected - - case 2: return .pairing(deeplink: try FfiConverterString.read(from: &buf) - ) - - case 3: return .connected(try FfiConverterTypeSessionUiInfo.read(from: &buf) - ) - - case 4: return .loginFailed(kind: try FfiConverterTypeLoginFailureKind.read(from: &buf), reason: try FfiConverterString.read(from: &buf) - ) - - case 5: return .authenticating - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: AuthState, into buf: inout [UInt8]) { - switch value { - - - case .disconnected: - writeInt(&buf, Int32(1)) - - - case let .pairing(deeplink): - writeInt(&buf, Int32(2)) - FfiConverterString.write(deeplink, into: &buf) - - - case let .connected(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeSessionUiInfo.write(v1, into: &buf) - - - case let .loginFailed(kind,reason): - writeInt(&buf, Int32(4)) - FfiConverterTypeLoginFailureKind.write(kind, into: &buf) - FfiConverterString.write(reason, into: &buf) - - - case .authenticating: - writeInt(&buf, Int32(5)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAuthState_lift(_ buf: RustBuffer) throws -> AuthState { - return try FfiConverterTypeAuthState.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAuthState_lower(_ value: AuthState) -> RustBuffer { - return FfiConverterTypeAuthState.lower(value) -} - - - -/** - * Review shown before a transaction-creation request is sent to the paired wallet. - */ - -public enum CreateTransactionReview: Equatable, Hashable { - - /** - * Product-account transaction request. - */ - case product(ProductAccountTxPayload - ) - /** - * Legacy-account transaction request. - */ - case legacyAccount(LegacyAccountTxPayload - ) - - - - - -} - -#if compiler(>=6) -extension CreateTransactionReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeCreateTransactionReview: FfiConverterRustBuffer { - typealias SwiftType = CreateTransactionReview - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CreateTransactionReview { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .product(try FfiConverterTypeProductAccountTxPayload.read(from: &buf) - ) - - case 2: return .legacyAccount(try FfiConverterTypeLegacyAccountTxPayload.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: CreateTransactionReview, into buf: inout [UInt8]) { - switch value { - - - case let .product(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeProductAccountTxPayload.write(v1, into: &buf) - - - case let .legacyAccount(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeLegacyAccountTxPayload.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateTransactionReview_lift(_ buf: RustBuffer) throws -> CreateTransactionReview { - return try FfiConverterTypeCreateTransactionReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateTransactionReview_lower(_ value: CreateTransactionReview) -> RustBuffer { - return FfiConverterTypeCreateTransactionReview.lower(value) -} - - - -/** - * What the operating system currently says about a device capability. - * - * Distinct from [`PermissionAuthorizationStatus`], which is the product-scoped - * decision the user made through TrUAPI. The two answer different questions - * and are combined rather than substituted: a capability is usable only when - * the product holds a grant *and* the OS still allows it. - */ - -public enum DevicePermissionStatus: Equatable, Hashable { - - /** - * The OS grants this capability to the host application. - */ - case granted - /** - * The OS refuses it. Prompting again will not help; the user has to - * change it in system settings. - */ - case denied - /** - * The OS has not been asked yet, either because it never was or because - * it reset the grant. The core does not treat this as a refusal: the OS - * puts its own dialog up when the capability is used, and the core has no - * way to reach that dialog without also re-asking the product's question. - */ - case notDetermined - /** - * This platform has no OS-level gate for the capability, so the - * product-scoped decision alone governs it. - */ - case notApplicable - - - - - -} - -#if compiler(>=6) -extension DevicePermissionStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeDevicePermissionStatus: FfiConverterRustBuffer { - typealias SwiftType = DevicePermissionStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DevicePermissionStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .granted - - case 2: return .denied - - case 3: return .notDetermined - - case 4: return .notApplicable - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: DevicePermissionStatus, into buf: inout [UInt8]) { - switch value { - - - case .granted: - writeInt(&buf, Int32(1)) - - - case .denied: - writeInt(&buf, Int32(2)) - - - case .notDetermined: - writeInt(&buf, Int32(3)) - - - case .notApplicable: - writeInt(&buf, Int32(4)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDevicePermissionStatus_lift(_ buf: RustBuffer) throws -> DevicePermissionStatus { - return try FfiConverterTypeDevicePermissionStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDevicePermissionStatus_lower(_ value: DevicePermissionStatus) -> RustBuffer { - return FfiConverterTypeDevicePermissionStatus.lower(value) -} - - - -/** - * Why a login attempt failed, for hosts that need to act on the cause rather - * than only display it. - */ - -public enum LoginFailureKind: Equatable, Hashable { - - /** - * The wallet has no free statement-store allowance slot for this period, - * so it cannot register the device — which normally holds until the period - * rolls over, making a retry a waste of the user's remaining budget. - * - * Recovered heuristically from the wallet's prose, whose wording is not - * this workspace's to pin, so treat it as a strong hint rather than a - * proof: do not make retry the primary action, but leave a way to reach it. - */ - case noFreeAllowanceSlots - /** - * Anything else. `reason` carries the detail. - */ - case other - - - - - -} - -#if compiler(>=6) -extension LoginFailureKind: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeLoginFailureKind: FfiConverterRustBuffer { - typealias SwiftType = LoginFailureKind - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LoginFailureKind { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .noFreeAllowanceSlots - - case 2: return .other - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: LoginFailureKind, into buf: inout [UInt8]) { - switch value { - - - case .noFreeAllowanceSlots: - writeInt(&buf, Int32(1)) - - - case .other: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeLoginFailureKind_lift(_ buf: RustBuffer) throws -> LoginFailureKind { - return try FfiConverterTypeLoginFailureKind.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeLoginFailureKind_lower(_ value: LoginFailureKind) -> RustBuffer { - return FfiConverterTypeLoginFailureKind.lower(value) -} - - - -/** - * Permission request whose authorization status can be inspected or updated - * by host administration UI. - */ - -public enum PermissionAuthorizationRequest: Equatable, Hashable { - - /** - * Device-level permission such as camera, microphone, or location. - */ - case device(HostDevicePermissionRequest - ) - /** - * Remote/product-scoped permission such as chain submit or HTTP access. - */ - case remote(RemotePermissionRequest - ) - /** - * Product-scoped permission to disclose the user's primary identity. - */ - case identityDisclosure - /** - * Product-scoped permission to access another product's account context. - */ - case accountAccess( - /** - * Product whose account context may be accessed. - */targetProductId: String - ) - - - - - -} - -#if compiler(>=6) -extension PermissionAuthorizationRequest: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePermissionAuthorizationRequest: FfiConverterRustBuffer { - typealias SwiftType = PermissionAuthorizationRequest - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PermissionAuthorizationRequest { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .device(try FfiConverterTypeHostDevicePermissionRequest.read(from: &buf) - ) - - case 2: return .remote(try FfiConverterTypeRemotePermissionRequest.read(from: &buf) - ) - - case 3: return .identityDisclosure - - case 4: return .accountAccess(targetProductId: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: PermissionAuthorizationRequest, into buf: inout [UInt8]) { - switch value { - - - case let .device(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeHostDevicePermissionRequest.write(v1, into: &buf) - - - case let .remote(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeRemotePermissionRequest.write(v1, into: &buf) - - - case .identityDisclosure: - writeInt(&buf, Int32(3)) - - - case let .accountAccess(targetProductId): - writeInt(&buf, Int32(4)) - FfiConverterString.write(targetProductId, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePermissionAuthorizationRequest_lift(_ buf: RustBuffer) throws -> PermissionAuthorizationRequest { - return try FfiConverterTypePermissionAuthorizationRequest.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePermissionAuthorizationRequest_lower(_ value: PermissionAuthorizationRequest) -> RustBuffer { - return FfiConverterTypePermissionAuthorizationRequest.lower(value) -} - - - -/** - * Authorization status for a permission request. - * - * `NotDetermined` means the core has no persisted answer and will prompt the - * host the next time the product requests this permission. - */ - -public enum PermissionAuthorizationStatus: Equatable, Hashable { - - /** - * No persisted authorization exists. - */ - case notDetermined - /** - * Access is denied. - */ - case denied - /** - * Access is authorized. - */ - case authorized - - - - - -} - -#if compiler(>=6) -extension PermissionAuthorizationStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePermissionAuthorizationStatus: FfiConverterRustBuffer { - typealias SwiftType = PermissionAuthorizationStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PermissionAuthorizationStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .notDetermined - - case 2: return .denied - - case 3: return .authorized - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: PermissionAuthorizationStatus, into buf: inout [UInt8]) { - switch value { - - - case .notDetermined: - writeInt(&buf, Int32(1)) - - - case .denied: - writeInt(&buf, Int32(2)) - - - case .authorized: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePermissionAuthorizationStatus_lift(_ buf: RustBuffer) throws -> PermissionAuthorizationStatus { - return try FfiConverterTypePermissionAuthorizationStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePermissionAuthorizationStatus_lower(_ value: PermissionAuthorizationStatus) -> RustBuffer { - return FfiConverterTypePermissionAuthorizationStatus.lower(value) -} - - - -/** - * Trusted kind of product executable attached to a TrUAPI connection. - * - * Mirrors the executable kinds a product manifest declares. The variants are - * capability classes: a connection reaches an execution-gated service only - * when its kind matches exactly, so `App` and `Widget` carry the same - * capability and differ only in how the host presents them, and `Worker` is - * the only kind that may serve the Chat modality. - */ - -public enum ProductExecutionKind: Equatable, Hashable { - - /** - * Visible full-page entrypoint such as `app/index.html`. - */ - case app - /** - * Visible embedded surface such as a dashboard card. - */ - case widget - /** - * Headless executable that serves the Chat modality. - */ - case worker - - - - - -} - -#if compiler(>=6) -extension ProductExecutionKind: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductExecutionKind: FfiConverterRustBuffer { - typealias SwiftType = ProductExecutionKind - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductExecutionKind { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .app - - case 2: return .widget - - case 3: return .worker - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ProductExecutionKind, into buf: inout [UInt8]) { - switch value { - - - case .app: - writeInt(&buf, Int32(1)) - - - case .widget: - writeInt(&buf, Int32(2)) - - - case .worker: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductExecutionKind_lift(_ buf: RustBuffer) throws -> ProductExecutionKind { - return try FfiConverterTypeProductExecutionKind.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductExecutionKind_lower(_ value: ProductExecutionKind) -> RustBuffer { - return FfiConverterTypeProductExecutionKind.lower(value) -} - - - -/** - * Review shown before a sign-payload request is sent to the paired wallet. - */ - -public enum SignPayloadReview: Equatable, Hashable { - - /** - * Product-account signing request. - */ - case product(HostSignPayloadRequest - ) - /** - * Legacy-account signing request. - */ - case legacyAccount(HostSignPayloadWithLegacyAccountRequest - ) - - - - - -} - -#if compiler(>=6) -extension SignPayloadReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSignPayloadReview: FfiConverterRustBuffer { - typealias SwiftType = SignPayloadReview - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignPayloadReview { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .product(try FfiConverterTypeHostSignPayloadRequest.read(from: &buf) - ) - - case 2: return .legacyAccount(try FfiConverterTypeHostSignPayloadWithLegacyAccountRequest.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SignPayloadReview, into buf: inout [UInt8]) { - switch value { - - - case let .product(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeHostSignPayloadRequest.write(v1, into: &buf) - - - case let .legacyAccount(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeHostSignPayloadWithLegacyAccountRequest.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignPayloadReview_lift(_ buf: RustBuffer) throws -> SignPayloadReview { - return try FfiConverterTypeSignPayloadReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignPayloadReview_lower(_ value: SignPayloadReview) -> RustBuffer { - return FfiConverterTypeSignPayloadReview.lower(value) -} - - - -/** - * Review shown before a sign-raw request is sent to the paired wallet. - */ - -public enum SignRawReview: Equatable, Hashable { - - /** - * Product-account raw signing request. - */ - case product(HostSignRawRequest - ) - /** - * Legacy-account raw signing request. - */ - case legacyAccount(HostSignRawWithLegacyAccountRequest - ) - - - - - -} - -#if compiler(>=6) -extension SignRawReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSignRawReview: FfiConverterRustBuffer { - typealias SwiftType = SignRawReview - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignRawReview { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .product(try FfiConverterTypeHostSignRawRequest.read(from: &buf) - ) - - case 2: return .legacyAccount(try FfiConverterTypeHostSignRawWithLegacyAccountRequest.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SignRawReview, into buf: inout [UInt8]) { - switch value { - - - case let .product(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeHostSignRawRequest.write(v1, into: &buf) - - - case let .legacyAccount(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeHostSignRawWithLegacyAccountRequest.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignRawReview_lift(_ buf: RustBuffer) throws -> SignRawReview { - return try FfiConverterTypeSignRawReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSignRawReview_lower(_ value: SignRawReview) -> RustBuffer { - return FfiConverterTypeSignRawReview.lower(value) -} - - - -/** - * Review shown before a user-confirmed core action continues. - */ - -public enum UserConfirmationReview: Equatable, Hashable { - - /** - * Sign a SCALE payload with a product or legacy account. - */ - case signPayload(SignPayloadReview - ) - /** - * Sign raw bytes with a product or legacy account. - */ - case signRaw(SignRawReview - ) - /** - * Sign a Statement Store proof payload with a product account. - */ - case statementStoreProductSign(StatementStoreProductSignReview - ) - /** - * Create a transaction with a product or legacy account. - */ - case createTransaction(CreateTransactionReview - ) - /** - * Allow a product to derive a contextual alias for a ring. - */ - case accountAlias(AccountAliasReview - ) - /** - * Allow a product to create a ring-VRF proof for a ring. - */ - case createProof(CreateProofReview - ) - /** - * Allow a product to learn the user's primary identity. - */ - case identityDisclosure(IdentityDisclosureReview - ) - /** - * Allocate resources for the requesting product. - */ - case resourceAllocation(ResourceAllocationReview - ) - /** - * Submit a preimage to the host-selected backend. - */ - case preimageSubmit(PreimageSubmitReview - ) - /** - * Allow a product to access another product account. - */ - case accountAccess(AccountAccessReview - ) - /** - * Sign an RFC-0023 VRF transcript with a product account. - */ - case signVrf(SignVrfReview - ) - /** - * Resolve a product's own account subtree over SSO. - */ - case productSubtree(ProductSubtreeReview - ) - - - - - -} - -#if compiler(>=6) -extension UserConfirmationReview: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeUserConfirmationReview: FfiConverterRustBuffer { - typealias SwiftType = UserConfirmationReview - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserConfirmationReview { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .signPayload(try FfiConverterTypeSignPayloadReview.read(from: &buf) - ) - - case 2: return .signRaw(try FfiConverterTypeSignRawReview.read(from: &buf) - ) - - case 3: return .statementStoreProductSign(try FfiConverterTypeStatementStoreProductSignReview.read(from: &buf) - ) - - case 4: return .createTransaction(try FfiConverterTypeCreateTransactionReview.read(from: &buf) - ) - - case 5: return .accountAlias(try FfiConverterTypeAccountAliasReview.read(from: &buf) - ) - - case 6: return .createProof(try FfiConverterTypeCreateProofReview.read(from: &buf) - ) - - case 7: return .identityDisclosure(try FfiConverterTypeIdentityDisclosureReview.read(from: &buf) - ) - - case 8: return .resourceAllocation(try FfiConverterTypeResourceAllocationReview.read(from: &buf) - ) - - case 9: return .preimageSubmit(try FfiConverterTypePreimageSubmitReview.read(from: &buf) - ) - - case 10: return .accountAccess(try FfiConverterTypeAccountAccessReview.read(from: &buf) - ) - - case 11: return .signVrf(try FfiConverterTypeSignVrfReview.read(from: &buf) - ) - - case 12: return .productSubtree(try FfiConverterTypeProductSubtreeReview.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: UserConfirmationReview, into buf: inout [UInt8]) { - switch value { - - - case let .signPayload(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeSignPayloadReview.write(v1, into: &buf) - - - case let .signRaw(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeSignRawReview.write(v1, into: &buf) - - - case let .statementStoreProductSign(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypeStatementStoreProductSignReview.write(v1, into: &buf) - - - case let .createTransaction(v1): - writeInt(&buf, Int32(4)) - FfiConverterTypeCreateTransactionReview.write(v1, into: &buf) - - - case let .accountAlias(v1): - writeInt(&buf, Int32(5)) - FfiConverterTypeAccountAliasReview.write(v1, into: &buf) - - - case let .createProof(v1): - writeInt(&buf, Int32(6)) - FfiConverterTypeCreateProofReview.write(v1, into: &buf) - - - case let .identityDisclosure(v1): - writeInt(&buf, Int32(7)) - FfiConverterTypeIdentityDisclosureReview.write(v1, into: &buf) - - - case let .resourceAllocation(v1): - writeInt(&buf, Int32(8)) - FfiConverterTypeResourceAllocationReview.write(v1, into: &buf) - - - case let .preimageSubmit(v1): - writeInt(&buf, Int32(9)) - FfiConverterTypePreimageSubmitReview.write(v1, into: &buf) - - - case let .accountAccess(v1): - writeInt(&buf, Int32(10)) - FfiConverterTypeAccountAccessReview.write(v1, into: &buf) - - - case let .signVrf(v1): - writeInt(&buf, Int32(11)) - FfiConverterTypeSignVrfReview.write(v1, into: &buf) - - - case let .productSubtree(v1): - writeInt(&buf, Int32(12)) - FfiConverterTypeProductSubtreeReview.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeUserConfirmationReview_lift(_ buf: RustBuffer) throws -> UserConfirmationReview { - return try FfiConverterTypeUserConfirmationReview.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeUserConfirmationReview_lower(_ value: UserConfirmationReview) -> RustBuffer { - return FfiConverterTypeUserConfirmationReview.lower(value) -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { - typealias SwiftType = String? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterString.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterString.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeBytes32: FfiConverterRustBuffer { - typealias SwiftType = Bytes32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeBytes32.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeBytes32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeHostChainEntry: FfiConverterRustBuffer { - typealias SwiftType = [HostChainEntry] - - public static func write(_ value: [HostChainEntry], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeHostChainEntry.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [HostChainEntry] { - let len: Int32 = try readInt(&buf) - var seq = [HostChainEntry]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeHostChainEntry.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeAllocatableResource: FfiConverterRustBuffer { - typealias SwiftType = [AllocatableResource] - - public static func write(_ value: [AllocatableResource], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeAllocatableResource.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AllocatableResource] { - let len: Int32 = try readInt(&buf) - var seq = [AllocatableResource]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeAllocatableResource.read(from: &buf)) - } - return seq - } -} - -private enum InitializationResult { - case ok - case contractVersionMismatch - case apiChecksumMismatch -} -// Use a global variable to perform the versioning checks. Swift ensures that -// the code inside is only computed once. -private let initializationResult: InitializationResult = { - // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 30 - // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_truapi_platform_uniffi_contract_version() - if bindings_contract_version != scaffolding_contract_version { - return InitializationResult.contractVersionMismatch - } - - uniffiEnsureTruapiInitialized() - return InitializationResult.ok -}() - -// Make the ensure init function public so that other modules which have external type references to -// our types can call it. -public func uniffiEnsureTruapiPlatformInitialized() { - switch initializationResult { - case .ok: - break - case .contractVersionMismatch: - fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") - case .apiChecksumMismatch: - fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } -} - -// swiftlint:enable all \ No newline at end of file diff --git a/ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift b/ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift deleted file mode 100644 index 437a02207..000000000 --- a/ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift +++ /dev/null @@ -1,6084 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -// swiftlint:disable all -import Foundation - -// Depending on the consumer's build setup, the low-level FFI code -// might be in a separate module, or it might be compiled inline into -// this module. This is a bit of light hackery to work with both. -#if canImport(truapi_serverFFI) -import truapi_serverFFI -#endif - -fileprivate extension RustBuffer { - // Allocate a new buffer, copying the contents of a `UInt8` array. - init(bytes: [UInt8]) { - let rbuf = bytes.withUnsafeBufferPointer { ptr in - RustBuffer.from(ptr) - } - self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) - } - - static func empty() -> RustBuffer { - RustBuffer(capacity: 0, len:0, data: nil) - } - - static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_truapi_server_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } - } - - // Frees the buffer in place. - // The buffer must not be used after this is called. - func deallocate() { - try! rustCall { ffi_truapi_server_rustbuffer_free(self, $0) } - } -} - -fileprivate extension ForeignBytes { - init(bufferPointer: UnsafeBufferPointer) { - 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(_ 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 -// lifting and lowering that type from C-compatible data, and for reading and writing -// values of that type in a buffer. - -// Helper classes/extensions that don't change. -// Someday, this will be in a library of its own. - -fileprivate extension Data { - init(rustBuffer: RustBuffer) { - self.init( - bytesNoCopy: rustBuffer.data!, - count: Int(rustBuffer.len), - deallocator: .none - ) - } -} - -// Define reader functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. -// -// With external types, one swift source file needs to be able to call the read -// method on another source file's FfiConverter, but then what visibility -// should Reader have? -// - If Reader is fileprivate, then this means the read() must also -// be fileprivate, which doesn't work with external types. -// - If Reader is internal/public, we'll get compile errors since both source -// files will try define the same type. -// -// Instead, the read() method and these helper functions input a tuple of data - -fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { - (data: data, offset: 0) -} - -// Reads an integer at the current offset, in big-endian order, and advances -// the offset on success. Throws if reading the integer would move the -// offset past the end of the buffer. -fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset...size - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - if T.self == UInt8.self { - let value = reader.data[reader.offset] - reader.offset += 1 - return value as! T - } - var value: T = 0 - let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) - reader.offset = range.upperBound - return value.bigEndian -} - -// Reads an arbitrary number of bytes, to be used to read -// raw bytes, this is useful when lifting strings -fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { - let range = reader.offset..<(reader.offset+count) - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - var value = [UInt8](repeating: 0, count: count) - value.withUnsafeMutableBufferPointer({ buffer in - reader.data.copyBytes(to: buffer, from: range) - }) - reader.offset = range.upperBound - return value -} - -// Reads a float at the current offset. -fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return Float(bitPattern: try readInt(&reader)) -} - -// Reads a float at the current offset. -fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return Double(bitPattern: try readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { - return reader.offset < reader.data.count -} - -// Define writer functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. See the above discussion on Readers for details. - -fileprivate func createWriter() -> [UInt8] { - return [] -} - -fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { - writer.append(contentsOf: byteArr) -} - -// Writes an integer in big-endian order. -// -// Warning: make sure what you are trying to write -// is in the correct type! -fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous to the Rust trait of the same name. -fileprivate protocol FfiConverter { - associatedtype FfiType - associatedtype SwiftType - - static func lift(_ value: FfiType) throws -> SwiftType - static func lower(_ value: SwiftType) -> FfiType - static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType - static func write(_ value: SwiftType, into buf: inout [UInt8]) -} - -// Types conforming to `Primitive` pass themselves directly over the FFI. -fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } - -extension FfiConverterPrimitive { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> FfiType { - return value - } -} - -// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. -// Used for complex types where it's hard to write a custom lift/lower. -fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ buf: RustBuffer) throws -> SwiftType { - var reader = createReader(data: Data(rustBuffer: buf)) - let value = try read(from: &reader) - if hasRemaining(reader) { - throw UniffiInternalError.incompleteData - } - buf.deallocate() - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> RustBuffer { - var writer = createWriter() - write(value, into: &writer) - return RustBuffer(bytes: writer) - } -} -// An error type for FFI errors. These errors occur at the UniFFI level, not -// the library level. -fileprivate enum UniffiInternalError: LocalizedError { - case bufferOverflow - case incompleteData - case unexpectedOptionalTag - case unexpectedEnumCase - case unexpectedNullPointer - case unexpectedRustCallStatusCode - case unexpectedRustCallError - case unexpectedStaleHandle - case rustPanic(_ message: String) - - public var errorDescription: String? { - switch self { - case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" - case .incompleteData: return "The buffer still has data after lifting its containing value" - case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" - case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" - case .unexpectedNullPointer: return "Raw pointer value was null" - case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" - case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" - case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" - case let .rustPanic(message): return message - } - } -} - -fileprivate extension NSLock { - func withLock(f: () throws -> T) rethrows -> T { - self.lock() - defer { self.unlock() } - return try f() - } -} - -fileprivate let CALL_SUCCESS: Int8 = 0 -fileprivate let CALL_ERROR: Int8 = 1 -fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 -fileprivate let CALL_CANCELLED: Int8 = 3 - -fileprivate extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer.init( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - let neverThrow: ((RustBuffer) throws -> Never)? = nil - return try makeRustCall(callback, errorHandler: neverThrow) -} - -private func rustCallWithError( - _ errorHandler: @escaping (RustBuffer) throws -> E, - _ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: errorHandler) -} - -private func makeRustCall( - _ callback: (UnsafeMutablePointer) -> T, - errorHandler: ((RustBuffer) throws -> E)? -) throws -> T { - uniffiEnsureTruapiServerInitialized() - var callStatus = RustCallStatus.init() - let returnedVal = callback(&callStatus) - try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) - return returnedVal -} - -private func uniffiCheckCallStatus( - callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> E)? -) throws { - switch callStatus.code { - case CALL_SUCCESS: - return - - case CALL_ERROR: - if let errorHandler = errorHandler { - throw try errorHandler(callStatus.errorBuf) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.unexpectedRustCallError - } - - case CALL_UNEXPECTED_ERROR: - // When the rust code sees a panic, it tries to construct a RustBuffer - // with the message. But if that code panics, then it just sends back - // an empty buffer. - if callStatus.errorBuf.len > 0 { - throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - case CALL_CANCELLED: - fatalError("Cancellation not supported yet") - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -private func uniffiTraitInterfaceCall( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> () -) { - do { - try writeReturn(makeCall()) - } catch let error { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) - } -} - -private func uniffiTraitInterfaceCallWithError( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> (), - lowerError: (E) -> RustBuffer -) { - do { - try writeReturn(makeCall()) - } catch let error as E { - callStatus.pointee.code = CALL_ERROR - callStatus.pointee.errorBuf = lowerError(error) - } catch { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - 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: @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 = UNIFFI_HANDLEMAP_INITIAL - - func insert(obj: T) -> UInt64 { - lock.withLock { - 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 { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - 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 { - guard let obj = map.removeValue(forKey: handle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - var count: Int { - get { - map.count - } - } -} - - -// Public interface members begin here. -// Magic number for the Rust proxy to call using the same mechanism as every other method, -// to free the callback once it's dropped by Rust. -private let IDX_CALLBACK_FREE: Int32 = 0 -// Callback return codes -private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 -private let UNIFFI_CALLBACK_ERROR: Int32 = 1 -private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt16: FfiConverterPrimitive { - typealias FfiType = UInt16 - typealias SwiftType = UInt16 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { - typealias FfiType = UInt32 - typealias SwiftType = UInt32 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { - typealias FfiType = UInt64 - typealias SwiftType = UInt64 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterBool : FfiConverter { - typealias FfiType = Int8 - typealias SwiftType = Bool - - public static func lift(_ value: Int8) throws -> Bool { - return value != 0 - } - - public static func lower(_ value: Bool) -> Int8 { - return value ? 1 : 0 - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { - return try lift(readInt(&buf)) - } - - public static func write(_ value: Bool, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterString: FfiConverter { - typealias SwiftType = String - typealias FfiType = RustBuffer - - public static func lift(_ value: RustBuffer) throws -> String { - defer { - value.deallocate() - } - if value.data == nil { - return String() - } - let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) - // 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 { - return value.utf8CString.withUnsafeBufferPointer { ptr in - // The swift string gives us int8_t, we want uint8_t. - ptr.withMemoryRebound(to: UInt8.self) { ptr in - // The swift string gives us a trailing null byte, we don't want it. - let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) - return RustBuffer.from(buf) - } - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { - let len: Int32 = try readInt(&buf) - // 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]) { - let len = Int32(value.utf8.count) - writeInt(&buf, len) - writeBytes(&buf, value.utf8) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterData: FfiConverterRustBuffer { - typealias SwiftType = Data - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { - let len: Int32 = try readInt(&buf) - return Data(try readBytes(&buf, count: Int(len))) - } - - public static func write(_ value: Data, into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - writeBytes(&buf, value) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterDuration: FfiConverterRustBuffer { - typealias SwiftType = TimeInterval - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TimeInterval { - let seconds: UInt64 = try readInt(&buf) - let nanoseconds: UInt32 = try readInt(&buf) - return Double(seconds) + (Double(nanoseconds) / 1.0e9) - } - - public static func write(_ value: TimeInterval, into buf: inout [UInt8]) { - if value.rounded(.down) > Double(Int64.max) { - fatalError("Duration overflow, exceeds max bounds supported by Uniffi") - } - - if value < 0 { - fatalError("Invalid duration, must be non-negative") - } - - let seconds = UInt64(value) - let nanoseconds = UInt32((value - Double(seconds)) * 1.0e9) - writeInt(&buf, seconds) - writeInt(&buf, nanoseconds) - } -} - - - - -/** - * Callback surface that iOS and Android implement. - * - * Threading contract: every callback executes on the shared bridge - * executor's worker threads, and blocking one of those threads can stall - * the entire bridge — not just the request being served. Async callbacks - * (`navigate_to`, `push_notification`, `device_permission`, - * `remote_permission`, `feature_supported`, `confirm_user_action`, - * `lookup_preimage`) are awaited by the core — implementations hop to the - * main thread for any UI and may keep the future pending arbitrarily long, - * but must suspend rather than block the polling thread (foreign - * implementations bridged through UniFFI suspend naturally; the rule - * chiefly binds Rust implementations). Dropping the returned future - * cancels the foreign task. The remaining sync callbacks run inline on the - * dispatcher thread and must return promptly without blocking; in - * particular `auth_state_changed` should only hand the state to the host - * UI thread, never wait for the user. - */ -public protocol HostCallbacks: AnyObject, Sendable { - - /** - * Lifecycle logger. Marker is a stable slug, detail is free-form. - */ - func onCoreLog(marker: String, detail: String) - - /** - * Open a URL in the system browser. - */ - func navigateTo(url: String) async throws - - /** - * Deliver a push notification. - */ - func pushNotification(request: HostPushNotificationRequest) async throws -> UInt32 - - /** - * Cancel a notification by id. - */ - func cancelNotification(id: UInt32) throws - - /** - * Prompt the user for a device-level permission (camera, mic, ...); - * the host returns whether the permission was granted. - */ - func devicePermission(request: HostDevicePermissionRequest) async throws -> Bool - - /** - * Report the OS status of a device capability without prompting. - * - * Answer from the platform's own authorization APIs. This must not show - * UI: the core calls it before every device-permission request and status - * read, and prompting here would re-ask a question the user has already - * answered. A host with no OS gate for the capability answers - * `NotApplicable`, which leaves the stored product decision governing. - * - * It is async because reading notification authorization on iOS is - * `UNUserNotificationCenter.getNotificationSettings(completionHandler:)`. - */ - func devicePermissionStatus(request: HostDevicePermissionRequest) async throws -> NativeDevicePermissionStatus - - /** - * Prompt the user for a remote (product-scoped) permission. - */ - func remotePermission(request: RemotePermission) async throws -> Bool - - /** - * Observe an auth state change, in transition order: render `Pairing` as - * the pairing QR UI, `Connected`/`Disconnected` as the account badge, - * `LoginFailed` as a retryable error unless its `kind` is - * `NoFreeAllowanceSlots`, which is unlikely to succeed before the period - * rolls over, so retry should not be the primary action. A pairing host's - * session activation reports its outcome even - * when it is the default `Disconnected`, so a host that awaits activation - * before routing never has to read silence as "signed out". Every other - * emission, and every emission on a host role that has no session - * activation, happens only when the state actually changes. - */ - func authStateChanged(state: AuthState) - - /** - * Read a core-owned host-private storage slot. `key` is a SCALE-encoded - * [`CoreStorageKey`]. - */ - func coreStorageRead(key: Data) throws -> Data? - - /** - * Persist a core-owned host-private storage slot. `key` is a - * SCALE-encoded [`CoreStorageKey`]. - */ - func coreStorageWrite(key: Data, value: Data) throws - - /** - * Clear a core-owned host-private storage slot. `key` is a SCALE-encoded - * [`CoreStorageKey`]. - */ - func coreStorageClear(key: Data) throws - - /** - * Open a JSON-RPC connection for a chain. Return a host-assigned - * connection id, or `None` when unsupported. - */ - func chainConnect(genesisHash: Data) throws -> UInt32? - - /** - * Send one JSON-RPC request over a previously opened chain connection. - */ - func chainSend(connectionId: UInt32, request: String) throws - - /** - * Close a previously opened chain connection. - */ - func chainClose(connectionId: UInt32) throws - - /** - * Confirm one user-reviewed core action. - */ - func confirmUserAction(review: UserConfirmationReview) async throws -> Bool - - /** - * Look up one preimage value by key. The native shim emits this as the - * current item in its subscription stream. - */ - func lookupPreimage(key: Data) async throws -> Data? - - /** - * Current host theme, named variant included. The native shim emits this - * as the current item in its subscription stream. - */ - func currentTheme() throws -> HostThemeSubscribeItem - - /** - * Locale the host currently presents its interface in. The native shim - * emits this as the current item in its subscription stream. - */ - func currentLocale() throws -> HostLocaleSubscribeItem - - /** - * Answer a feature-support query. - */ - func featureSupported(request: HostFeatureSupportedRequest) async throws -> Bool - - /** - * Enumerate the chains this host serves (RFC 0026): its environment plus - * one entry per chain role. Invoked on the dispatcher thread; must return - * promptly. - */ - func supportedChains() throws -> HostChainSet - - /** - * Read a value from the host's scoped key-value store. - */ - func localStorageRead(key: String) throws -> Data? - - /** - * Write a value to the host's scoped key-value store. - */ - func localStorageWrite(key: String, value: Data) throws - - /** - * Clear a value from the host's scoped key-value store. - */ - func localStorageClear(key: String) throws - -} -/** - * Callback surface that iOS and Android implement. - * - * Threading contract: every callback executes on the shared bridge - * executor's worker threads, and blocking one of those threads can stall - * the entire bridge — not just the request being served. Async callbacks - * (`navigate_to`, `push_notification`, `device_permission`, - * `remote_permission`, `feature_supported`, `confirm_user_action`, - * `lookup_preimage`) are awaited by the core — implementations hop to the - * main thread for any UI and may keep the future pending arbitrarily long, - * but must suspend rather than block the polling thread (foreign - * implementations bridged through UniFFI suspend naturally; the rule - * chiefly binds Rust implementations). Dropping the returned future - * cancels the foreign task. The remaining sync callbacks run inline on the - * dispatcher thread and must return promptly without blocking; in - * particular `auth_state_changed` should only hand the state to the host - * UI thread, never wait for the user. - */ -open class HostCallbacksImpl: HostCallbacks, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_server_fn_clone_hostcallbacks(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_server_fn_free_hostcallbacks(handle, $0) } - } - - - - - /** - * Lifecycle logger. Marker is a stable slug, detail is free-form. - */ -open func onCoreLog(marker: String, detail: String) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_on_core_log( - self.uniffiCloneHandle(), - FfiConverterString.lower(marker), - FfiConverterString.lower(detail),uniffiCallStatus - ) -} -} - - /** - * Open a URL in the system browser. - */ -open func navigateTo(url: String)async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_navigate_to( - self.uniffiCloneHandle(),FfiConverterString.lower(url) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_void, - completeFunc: ffi_truapi_server_rust_future_complete_void, - freeFunc: ffi_truapi_server_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypeHostNavigateRejection_lift - ) -} - - /** - * Deliver a push notification. - */ -open func pushNotification(request: HostPushNotificationRequest)async throws -> UInt32 { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_push_notification( - self.uniffiCloneHandle(),FfiConverterTypeHostPushNotificationRequest_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_u32, - completeFunc: ffi_truapi_server_rust_future_complete_u32, - freeFunc: ffi_truapi_server_rust_future_free_u32, - liftFunc: FfiConverterUInt32.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Cancel a notification by id. - */ -open func cancelNotification(id: UInt32)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_cancel_notification( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(id),uniffiCallStatus - ) -} -} - - /** - * Prompt the user for a device-level permission (camera, mic, ...); - * the host returns whether the permission was granted. - */ -open func devicePermission(request: HostDevicePermissionRequest)async throws -> Bool { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_device_permission( - self.uniffiCloneHandle(),FfiConverterTypeHostDevicePermissionRequest_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_i8, - completeFunc: ffi_truapi_server_rust_future_complete_i8, - freeFunc: ffi_truapi_server_rust_future_free_i8, - liftFunc: FfiConverterBool.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Report the OS status of a device capability without prompting. - * - * Answer from the platform's own authorization APIs. This must not show - * UI: the core calls it before every device-permission request and status - * read, and prompting here would re-ask a question the user has already - * answered. A host with no OS gate for the capability answers - * `NotApplicable`, which leaves the stored product decision governing. - * - * It is async because reading notification authorization on iOS is - * `UNUserNotificationCenter.getNotificationSettings(completionHandler:)`. - */ -open func devicePermissionStatus(request: HostDevicePermissionRequest)async throws -> NativeDevicePermissionStatus { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_device_permission_status( - self.uniffiCloneHandle(),FfiConverterTypeHostDevicePermissionRequest_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_rust_buffer, - completeFunc: ffi_truapi_server_rust_future_complete_rust_buffer, - freeFunc: ffi_truapi_server_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeNativeDevicePermissionStatus_lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Prompt the user for a remote (product-scoped) permission. - */ -open func remotePermission(request: RemotePermission)async throws -> Bool { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_remote_permission( - self.uniffiCloneHandle(),FfiConverterTypeRemotePermission_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_i8, - completeFunc: ffi_truapi_server_rust_future_complete_i8, - freeFunc: ffi_truapi_server_rust_future_free_i8, - liftFunc: FfiConverterBool.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Observe an auth state change, in transition order: render `Pairing` as - * the pairing QR UI, `Connected`/`Disconnected` as the account badge, - * `LoginFailed` as a retryable error unless its `kind` is - * `NoFreeAllowanceSlots`, which is unlikely to succeed before the period - * rolls over, so retry should not be the primary action. A pairing host's - * session activation reports its outcome even - * when it is the default `Disconnected`, so a host that awaits activation - * before routing never has to read silence as "signed out". Every other - * emission, and every emission on a host role that has no session - * activation, happens only when the state actually changes. - */ -open func authStateChanged(state: AuthState) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_auth_state_changed( - self.uniffiCloneHandle(), - FfiConverterTypeAuthState_lower(state),uniffiCallStatus - ) -} -} - - /** - * Read a core-owned host-private storage slot. `key` is a SCALE-encoded - * [`CoreStorageKey`]. - */ -open func coreStorageRead(key: Data)throws -> Data? { - return try FfiConverterOptionData.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_core_storage_read( - self.uniffiCloneHandle(), - FfiConverterData.lower(key),uniffiCallStatus - ) -}) -} - - /** - * Persist a core-owned host-private storage slot. `key` is a - * SCALE-encoded [`CoreStorageKey`]. - */ -open func coreStorageWrite(key: Data, value: Data)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_core_storage_write( - self.uniffiCloneHandle(), - FfiConverterData.lower(key), - FfiConverterData.lower(value),uniffiCallStatus - ) -} -} - - /** - * Clear a core-owned host-private storage slot. `key` is a SCALE-encoded - * [`CoreStorageKey`]. - */ -open func coreStorageClear(key: Data)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_core_storage_clear( - self.uniffiCloneHandle(), - FfiConverterData.lower(key),uniffiCallStatus - ) -} -} - - /** - * Open a JSON-RPC connection for a chain. Return a host-assigned - * connection id, or `None` when unsupported. - */ -open func chainConnect(genesisHash: Data)throws -> UInt32? { - return try FfiConverterOptionUInt32.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_chain_connect( - self.uniffiCloneHandle(), - FfiConverterData.lower(genesisHash),uniffiCallStatus - ) -}) -} - - /** - * Send one JSON-RPC request over a previously opened chain connection. - */ -open func chainSend(connectionId: UInt32, request: String)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_chain_send( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId), - FfiConverterString.lower(request),uniffiCallStatus - ) -} -} - - /** - * Close a previously opened chain connection. - */ -open func chainClose(connectionId: UInt32)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_chain_close( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId),uniffiCallStatus - ) -} -} - - /** - * Confirm one user-reviewed core action. - */ -open func confirmUserAction(review: UserConfirmationReview)async throws -> Bool { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_confirm_user_action( - self.uniffiCloneHandle(),FfiConverterTypeUserConfirmationReview_lower(review) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_i8, - completeFunc: ffi_truapi_server_rust_future_complete_i8, - freeFunc: ffi_truapi_server_rust_future_free_i8, - liftFunc: FfiConverterBool.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Look up one preimage value by key. The native shim emits this as the - * current item in its subscription stream. - */ -open func lookupPreimage(key: Data)async throws -> Data? { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_lookup_preimage( - self.uniffiCloneHandle(),FfiConverterData.lower(key) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_rust_buffer, - completeFunc: ffi_truapi_server_rust_future_complete_rust_buffer, - freeFunc: ffi_truapi_server_rust_future_free_rust_buffer, - liftFunc: FfiConverterOptionData.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Current host theme, named variant included. The native shim emits this - * as the current item in its subscription stream. - */ -open func currentTheme()throws -> HostThemeSubscribeItem { - return try FfiConverterTypeHostThemeSubscribeItem_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_current_theme( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Locale the host currently presents its interface in. The native shim - * emits this as the current item in its subscription stream. - */ -open func currentLocale()throws -> HostLocaleSubscribeItem { - return try FfiConverterTypeHostLocaleSubscribeItem_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_current_locale( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Answer a feature-support query. - */ -open func featureSupported(request: HostFeatureSupportedRequest)async throws -> Bool { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_hostcallbacks_feature_supported( - self.uniffiCloneHandle(),FfiConverterTypeHostFeatureSupportedRequest_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_i8, - completeFunc: ffi_truapi_server_rust_future_complete_i8, - freeFunc: ffi_truapi_server_rust_future_free_i8, - liftFunc: FfiConverterBool.lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Enumerate the chains this host serves (RFC 0026): its environment plus - * one entry per chain role. Invoked on the dispatcher thread; must return - * promptly. - */ -open func supportedChains()throws -> HostChainSet { - return try FfiConverterTypeHostChainSet_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_supported_chains( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Read a value from the host's scoped key-value store. - */ -open func localStorageRead(key: String)throws -> Data? { - return try FfiConverterOptionData.lift(try rustCallWithError(FfiConverterTypeHostStorageError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_local_storage_read( - self.uniffiCloneHandle(), - FfiConverterString.lower(key),uniffiCallStatus - ) -}) -} - - /** - * Write a value to the host's scoped key-value store. - */ -open func localStorageWrite(key: String, value: Data)throws {try rustCallWithError(FfiConverterTypeHostStorageError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_local_storage_write( - self.uniffiCloneHandle(), - FfiConverterString.lower(key), - FfiConverterData.lower(value),uniffiCallStatus - ) -} -} - - /** - * Clear a value from the host's scoped key-value store. - */ -open func localStorageClear(key: String)throws {try rustCallWithError(FfiConverterTypeHostStorageError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_hostcallbacks_local_storage_clear( - self.uniffiCloneHandle(), - FfiConverterString.lower(key),uniffiCallStatus - ) -} -} - - - -} - - - -// Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceHostCallbacks { - - // Create the VTable using a series of closures. - // Swift automatically converts these into C callback functions. - // - // Store the vtable directly. - static let vtable: UniffiVTableCallbackInterfaceHostCallbacks = UniffiVTableCallbackInterfaceHostCallbacks( - uniffiFree: { (uniffiHandle: UInt64) -> () in - do { - try FfiConverterTypeHostCallbacks.handleMap.remove(handle: uniffiHandle) - } catch { - print("Uniffi callback interface HostCallbacks: handle missing in uniffiFree") - } - }, - uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in - do { - return try FfiConverterTypeHostCallbacks.handleMap.clone(handle: uniffiHandle) - } catch { - fatalError("Uniffi callback interface HostCallbacks: handle missing in uniffiClone") - } - }, - onCoreLog: { ( - uniffiHandle: UInt64, - marker: RustBuffer, - detail: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onCoreLog( - marker: try FfiConverterString.lift(marker), - detail: try FfiConverterString.lift(detail) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - navigateTo: { ( - uniffiHandle: UInt64, - url: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteVoid, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.navigateTo( - url: try FfiConverterString.lift(url) - ) - } - - let uniffiHandleSuccess = { (returnValue: ()) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultVoid( - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultVoid( - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostNavigateRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - pushNotification: { ( - uniffiHandle: UInt64, - request: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteU32, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> UInt32 in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.pushNotification( - request: try FfiConverterTypeHostPushNotificationRequest_lift(request) - ) - } - - let uniffiHandleSuccess = { (returnValue: UInt32) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultU32( - returnValue: FfiConverterUInt32.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultU32( - returnValue: 0, - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - cancelNotification: { ( - uniffiHandle: UInt64, - id: UInt32, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.cancelNotification( - id: try FfiConverterUInt32.lift(id) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - devicePermission: { ( - uniffiHandle: UInt64, - request: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteI8, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> Bool in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.devicePermission( - request: try FfiConverterTypeHostDevicePermissionRequest_lift(request) - ) - } - - let uniffiHandleSuccess = { (returnValue: Bool) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: FfiConverterBool.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: 0, - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - devicePermissionStatus: { ( - uniffiHandle: UInt64, - request: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> NativeDevicePermissionStatus in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.devicePermissionStatus( - request: try FfiConverterTypeHostDevicePermissionRequest_lift(request) - ) - } - - let uniffiHandleSuccess = { (returnValue: NativeDevicePermissionStatus) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultRustBuffer( - returnValue: FfiConverterTypeNativeDevicePermissionStatus_lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultRustBuffer( - returnValue: RustBuffer.empty(), - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - remotePermission: { ( - uniffiHandle: UInt64, - request: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteI8, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> Bool in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.remotePermission( - request: try FfiConverterTypeRemotePermission_lift(request) - ) - } - - let uniffiHandleSuccess = { (returnValue: Bool) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: FfiConverterBool.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: 0, - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - authStateChanged: { ( - uniffiHandle: UInt64, - state: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.authStateChanged( - state: try FfiConverterTypeAuthState_lift(state) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - coreStorageRead: { ( - uniffiHandle: UInt64, - key: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> Data? in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.coreStorageRead( - key: try FfiConverterData.lift(key) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionData.lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - coreStorageWrite: { ( - uniffiHandle: UInt64, - key: RustBuffer, - value: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.coreStorageWrite( - key: try FfiConverterData.lift(key), - value: try FfiConverterData.lift(value) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - coreStorageClear: { ( - uniffiHandle: UInt64, - key: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.coreStorageClear( - key: try FfiConverterData.lift(key) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - chainConnect: { ( - uniffiHandle: UInt64, - genesisHash: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> UInt32? in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.chainConnect( - genesisHash: try FfiConverterData.lift(genesisHash) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionUInt32.lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - chainSend: { ( - uniffiHandle: UInt64, - connectionId: UInt32, - request: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.chainSend( - connectionId: try FfiConverterUInt32.lift(connectionId), - request: try FfiConverterString.lift(request) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - chainClose: { ( - uniffiHandle: UInt64, - connectionId: UInt32, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.chainClose( - connectionId: try FfiConverterUInt32.lift(connectionId) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - confirmUserAction: { ( - uniffiHandle: UInt64, - review: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteI8, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> Bool in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.confirmUserAction( - review: try FfiConverterTypeUserConfirmationReview_lift(review) - ) - } - - let uniffiHandleSuccess = { (returnValue: Bool) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: FfiConverterBool.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: 0, - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - lookupPreimage: { ( - uniffiHandle: UInt64, - key: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> Data? in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.lookupPreimage( - key: try FfiConverterData.lift(key) - ) - } - - let uniffiHandleSuccess = { (returnValue: Data?) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultRustBuffer( - returnValue: FfiConverterOptionData.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultRustBuffer( - returnValue: RustBuffer.empty(), - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - currentTheme: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> HostThemeSubscribeItem in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.currentTheme( - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeHostThemeSubscribeItem_lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - currentLocale: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> HostLocaleSubscribeItem in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.currentLocale( - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeHostLocaleSubscribeItem_lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - featureSupported: { ( - uniffiHandle: UInt64, - request: RustBuffer, - uniffiFutureCallback: @escaping UniffiForeignFutureCompleteI8, - uniffiCallbackData: UInt64, - uniffiOutDroppedCallback: UnsafeMutablePointer - ) in - let makeCall = { - () async throws -> Bool in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try await uniffiObj.featureSupported( - request: try FfiConverterTypeHostFeatureSupportedRequest_lift(request) - ) - } - - let uniffiHandleSuccess = { (returnValue: Bool) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: FfiConverterBool.lower(returnValue), - callStatus: RustCallStatus() - ) - ) - } - let uniffiHandleError = { (statusCode, errorBuf) in - uniffiFutureCallback( - uniffiCallbackData, - UniffiForeignFutureResultI8( - returnValue: 0, - callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) - ) - ) - } - uniffiTraitInterfaceCallAsyncWithError( - makeCall: makeCall, - handleSuccess: uniffiHandleSuccess, - handleError: uniffiHandleError, - lowerError: FfiConverterTypeHostRejection_lower, - droppedCallback: uniffiOutDroppedCallback - ) - }, - supportedChains: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> HostChainSet in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.supportedChains( - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeHostChainSet_lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - localStorageRead: { ( - uniffiHandle: UInt64, - key: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> Data? in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.localStorageRead( - key: try FfiConverterString.lift(key) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionData.lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostStorageError_lower - ) - }, - localStorageWrite: { ( - uniffiHandle: UInt64, - key: RustBuffer, - value: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.localStorageWrite( - key: try FfiConverterString.lift(key), - value: try FfiConverterData.lift(value) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostStorageError_lower - ) - }, - localStorageClear: { ( - uniffiHandle: UInt64, - key: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeHostCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.localStorageClear( - key: try FfiConverterString.lift(key) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostStorageError_lower - ) - } - ) - - // Rust stores this pointer for future callback invocations, so it must live - // for the process lifetime (not just for the init function call). - // - // `nonisolated(unsafe)` is needed under Swift 6 strict concurrency. - // This is safe because the pointee is initialized once during static init - // and never mutated by either side of the FFI. Its fields are C function pointers. - nonisolated(unsafe) static let vtablePtr: UnsafePointer = { - let ptr = UnsafeMutablePointer.allocate(capacity: 1) - ptr.initialize(to: vtable) - return UnsafePointer(ptr) - }() -} - -private func uniffiCallbackInitHostCallbacks() { - uniffi_truapi_server_fn_init_callback_vtable_hostcallbacks(UniffiCallbackInterfaceHostCallbacks.vtablePtr) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostCallbacks: FfiConverter { - fileprivate static let handleMap = UniffiHandleMap() - - typealias FfiType = UInt64 - typealias SwiftType = HostCallbacks - - public static func lift(_ handle: UInt64) throws -> HostCallbacks { - if ((handle & 1) == 0) { - // Rust-generated handle, construct a new class that uses the handle to implement the - // interface - return HostCallbacksImpl(unsafeFromHandle: handle) - } else { - // Swift-generated handle, get the object from the handle map - return try handleMap.remove(handle: handle) - } - } - - public static func lower(_ value: HostCallbacks) -> UInt64 { - if let rustImpl = value as? HostCallbacksImpl { - // Rust-implemented object. Clone the handle and return it - return rustImpl.uniffiCloneHandle() - } else { - // Swift object, generate a new vtable handle and return that. - return handleMap.insert(obj: value) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostCallbacks { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: HostCallbacks, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostCallbacks_lift(_ handle: UInt64) throws -> HostCallbacks { - return try FfiConverterTypeHostCallbacks.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostCallbacks_lower(_ value: HostCallbacks) -> UInt64 { - return FfiConverterTypeHostCallbacks.lower(value) -} - - - - - - -/** - * Native Chat storage and UI adapter. Hosts that support the Chat modality - * pass an implementation to - * [`NativeTrUApiHostRuntime::open_product_execution`]; hosts that do not - * simply pass `None`. Callbacks run inline on the process-wide dispatch pool - * shared by every product execution, so one that blocks stalls the others. - */ -public protocol NativeChatCallbacks: AnyObject, Sendable { - - /** - * Create or resolve a native product Chat room. - */ - func createRoom(roomId: String, name: String, icon: String) throws -> ChatRoomRegistrationStatus - - /** - * Register or resolve a native product Chat bot. - */ - func registerBot(botId: String, name: String, icon: String) throws -> ChatBotRegistrationStatus - - /** - * Persist a product-authored message in native Chat storage. A host that - * cannot render a given content variant returns a rejection for it. - * - * The returned id is what [`ActionTrigger::message_id`] carries back, so - * it must name this message for as long as the host stores it. - * - * [`ActionTrigger::message_id`]: truapi::latest::ActionTrigger - */ - func postMessage(roomId: String, content: ChatMessageContent) throws -> String - - /** - * Return the current product-scoped native Chat room list. - */ - func listRooms() throws -> [ChatRoom] - -} -/** - * Native Chat storage and UI adapter. Hosts that support the Chat modality - * pass an implementation to - * [`NativeTrUApiHostRuntime::open_product_execution`]; hosts that do not - * simply pass `None`. Callbacks run inline on the process-wide dispatch pool - * shared by every product execution, so one that blocks stalls the others. - */ -open class NativeChatCallbacksImpl: NativeChatCallbacks, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_server_fn_clone_nativechatcallbacks(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_server_fn_free_nativechatcallbacks(handle, $0) } - } - - - - - /** - * Create or resolve a native product Chat room. - */ -open func createRoom(roomId: String, name: String, icon: String)throws -> ChatRoomRegistrationStatus { - return try FfiConverterTypeChatRoomRegistrationStatus_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativechatcallbacks_create_room( - self.uniffiCloneHandle(), - FfiConverterString.lower(roomId), - FfiConverterString.lower(name), - FfiConverterString.lower(icon),uniffiCallStatus - ) -}) -} - - /** - * Register or resolve a native product Chat bot. - */ -open func registerBot(botId: String, name: String, icon: String)throws -> ChatBotRegistrationStatus { - return try FfiConverterTypeChatBotRegistrationStatus_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativechatcallbacks_register_bot( - self.uniffiCloneHandle(), - FfiConverterString.lower(botId), - FfiConverterString.lower(name), - FfiConverterString.lower(icon),uniffiCallStatus - ) -}) -} - - /** - * Persist a product-authored message in native Chat storage. A host that - * cannot render a given content variant returns a rejection for it. - * - * The returned id is what [`ActionTrigger::message_id`] carries back, so - * it must name this message for as long as the host stores it. - * - * [`ActionTrigger::message_id`]: truapi::latest::ActionTrigger - */ -open func postMessage(roomId: String, content: ChatMessageContent)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativechatcallbacks_post_message( - self.uniffiCloneHandle(), - FfiConverterString.lower(roomId), - FfiConverterTypeChatMessageContent_lower(content),uniffiCallStatus - ) -}) -} - - /** - * Return the current product-scoped native Chat room list. - */ -open func listRooms()throws -> [ChatRoom] { - return try FfiConverterSequenceTypeChatRoom.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativechatcallbacks_list_rooms( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - - -} - - - -// Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceNativeChatCallbacks { - - // Create the VTable using a series of closures. - // Swift automatically converts these into C callback functions. - // - // Store the vtable directly. - static let vtable: UniffiVTableCallbackInterfaceNativeChatCallbacks = UniffiVTableCallbackInterfaceNativeChatCallbacks( - uniffiFree: { (uniffiHandle: UInt64) -> () in - do { - try FfiConverterTypeNativeChatCallbacks.handleMap.remove(handle: uniffiHandle) - } catch { - print("Uniffi callback interface NativeChatCallbacks: handle missing in uniffiFree") - } - }, - uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in - do { - return try FfiConverterTypeNativeChatCallbacks.handleMap.clone(handle: uniffiHandle) - } catch { - fatalError("Uniffi callback interface NativeChatCallbacks: handle missing in uniffiClone") - } - }, - createRoom: { ( - uniffiHandle: UInt64, - roomId: RustBuffer, - name: RustBuffer, - icon: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> ChatRoomRegistrationStatus in - guard let uniffiObj = try? FfiConverterTypeNativeChatCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.createRoom( - roomId: try FfiConverterString.lift(roomId), - name: try FfiConverterString.lift(name), - icon: try FfiConverterString.lift(icon) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeChatRoomRegistrationStatus_lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - registerBot: { ( - uniffiHandle: UInt64, - botId: RustBuffer, - name: RustBuffer, - icon: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> ChatBotRegistrationStatus in - guard let uniffiObj = try? FfiConverterTypeNativeChatCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.registerBot( - botId: try FfiConverterString.lift(botId), - name: try FfiConverterString.lift(name), - icon: try FfiConverterString.lift(icon) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeChatBotRegistrationStatus_lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - postMessage: { ( - uniffiHandle: UInt64, - roomId: RustBuffer, - content: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> String in - guard let uniffiObj = try? FfiConverterTypeNativeChatCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.postMessage( - roomId: try FfiConverterString.lift(roomId), - content: try FfiConverterTypeChatMessageContent_lift(content) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - }, - listRooms: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> [ChatRoom] in - guard let uniffiObj = try? FfiConverterTypeNativeChatCallbacks.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.listRooms( - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterSequenceTypeChatRoom.lower($0) } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeHostRejection_lower - ) - } - ) - - // Rust stores this pointer for future callback invocations, so it must live - // for the process lifetime (not just for the init function call). - // - // `nonisolated(unsafe)` is needed under Swift 6 strict concurrency. - // This is safe because the pointee is initialized once during static init - // and never mutated by either side of the FFI. Its fields are C function pointers. - nonisolated(unsafe) static let vtablePtr: UnsafePointer = { - let ptr = UnsafeMutablePointer.allocate(capacity: 1) - ptr.initialize(to: vtable) - return UnsafePointer(ptr) - }() -} - -private func uniffiCallbackInitNativeChatCallbacks() { - uniffi_truapi_server_fn_init_callback_vtable_nativechatcallbacks(UniffiCallbackInterfaceNativeChatCallbacks.vtablePtr) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeChatCallbacks: FfiConverter { - fileprivate static let handleMap = UniffiHandleMap() - - typealias FfiType = UInt64 - typealias SwiftType = NativeChatCallbacks - - public static func lift(_ handle: UInt64) throws -> NativeChatCallbacks { - if ((handle & 1) == 0) { - // Rust-generated handle, construct a new class that uses the handle to implement the - // interface - return NativeChatCallbacksImpl(unsafeFromHandle: handle) - } else { - // Swift-generated handle, get the object from the handle map - return try handleMap.remove(handle: handle) - } - } - - public static func lower(_ value: NativeChatCallbacks) -> UInt64 { - if let rustImpl = value as? NativeChatCallbacksImpl { - // Rust-implemented object. Clone the handle and return it - return rustImpl.uniffiCloneHandle() - } else { - // Swift object, generate a new vtable handle and return that. - return handleMap.insert(obj: value) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeChatCallbacks { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: NativeChatCallbacks, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeChatCallbacks_lift(_ handle: UInt64) throws -> NativeChatCallbacks { - return try FfiConverterTypeNativeChatCallbacks.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeChatCallbacks_lower(_ value: NativeChatCallbacks) -> UInt64 { - return FfiConverterTypeNativeChatCallbacks.lower(value) -} - - - - - - -/** - * Cancellable native observation of one custom-message render instance. - */ -public protocol NativeCustomRendererSubscriptionProtocol: AnyObject, Sendable { - - /** - * Stop delivering renderer updates to the native observer. - */ - func cancel() - -} -/** - * Cancellable native observation of one custom-message render instance. - */ -open class NativeCustomRendererSubscription: NativeCustomRendererSubscriptionProtocol, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_server_fn_clone_nativecustomrenderersubscription(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_server_fn_free_nativecustomrenderersubscription(handle, $0) } - } - - - - - /** - * Stop delivering renderer updates to the native observer. - */ -open func cancel() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativecustomrenderersubscription_cancel( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - - -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeCustomRendererSubscription: FfiConverter { - typealias FfiType = UInt64 - typealias SwiftType = NativeCustomRendererSubscription - - public static func lift(_ handle: UInt64) throws -> NativeCustomRendererSubscription { - return NativeCustomRendererSubscription(unsafeFromHandle: handle) - } - - public static func lower(_ value: NativeCustomRendererSubscription) -> UInt64 { - return value.uniffiCloneHandle() - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeCustomRendererSubscription { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: NativeCustomRendererSubscription, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeCustomRendererSubscription_lift(_ handle: UInt64) throws -> NativeCustomRendererSubscription { - return try FfiConverterTypeNativeCustomRendererSubscription.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeCustomRendererSubscription_lower(_ value: NativeCustomRendererSubscription) -> UInt64 { - return FfiConverterTypeNativeCustomRendererSubscription.lower(value) -} - - - - - - -/** - * One native executable connection opened from a process-owned host runtime. - */ -public protocol NativeProductExecutionProtocol: AnyObject, Sendable { - - /** - * Read this device's X25519 encryption secret, for device sync against a - * peer's `deviceEncPublicKey`. Generated and persisted on first read. - */ - func deviceEncryptionKey() throws -> Bytes32 - - /** - * Notify this execution's chain adapter that a connection closed. - */ - func notifyChainClosed(connectionId: UInt32) - - /** - * Notify this execution's chain adapter of one JSON-RPC response. - */ - func notifyChainResponse(connectionId: UInt32, json: String) - - /** - * Push a complete native Chat room-list replacement to this execution. - */ - func notifyChatRoomsChanged(rooms: [ChatRoom]) - - /** - * Push a host locale replacement to this execution's subscriptions. - */ - func notifyLocaleChanged(locale: HostLocaleSubscribeItem) - - /** - * Push a preimage lookup replacement to this execution's subscriptions. - */ - func notifyPreimageChanged(key: Data, value: Data?) - - /** - * Push a host theme replacement to this execution's subscriptions. - */ - func notifyThemeChanged(theme: HostThemeSubscribeItem) - - /** - * Read a product-scoped permission authorization without prompting. - * - * A device capability resolves the host application's OS gate as well as - * storage, which means calling `device_permission_status` on the host. It - * is async for that reason: blocking a thread on a host callback - * deadlocks any implementation that hops to the same thread to answer. - */ - func permissionAuthorizationStatus(request: PermissionAuthorizationRequest) async throws -> PermissionAuthorizationStatus - - /** - * Resolve a product's hard-subtree public key for hosts naming the account - * a review will sign with. Answers from the cache, the persisted slot, or - * the Account Holder, and `timeout_ms` bounds that wait. Exceeding it is - * an error; `None` means no active session. - */ - func productSubtreePublicKey(productId: String, timeoutMs: UInt32?) throws -> Bytes32? - - /** - * Publish one native Chat action, buffering it until the product - * connection subscribes. - */ - func publishChatAction(action: HostChatActionSubscribeItem) throws - - /** - * Request typed native UI for one stored custom Chat message. - */ - func renderCustomMessage(messageId: String, messageType: String, payload: Data, observer: NativeCustomRendererObserver) throws -> NativeCustomRendererSubscription - - /** - * Read the active session's X25519 chat identity private key, or `None` - * when no session is active. - */ - func sessionChatIdentityKey() throws -> Bytes32? - - /** - * Update a product-scoped permission authorization. - */ - func setPermissionAuthorizationStatus(request: PermissionAuthorizationRequest, status: PermissionAuthorizationStatus) throws - - /** - * Permanently shut down this executable and all of its connection state. - * - * This is named `shutdown` rather than `close` because UniFFI Kotlin - * objects already implement `AutoCloseable.close()` for releasing the - * foreign object handle. - */ - func shutdown() - - /** - * Start this execution's independently authenticated localhost bridge. - */ - func startWsBridge(bindPort: UInt16) throws -> WsBridgeEndpoint - - /** - * Stop the active bridge while leaving the execution reusable. - */ - func stopWsBridge() - -} -/** - * One native executable connection opened from a process-owned host runtime. - */ -open class NativeProductExecution: NativeProductExecutionProtocol, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_server_fn_clone_nativeproductexecution(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_server_fn_free_nativeproductexecution(handle, $0) } - } - - - - - /** - * Read this device's X25519 encryption secret, for device sync against a - * peer's `deviceEncPublicKey`. Generated and persisted on first read. - */ -open func deviceEncryptionKey()throws -> Bytes32 { - return try FfiConverterTypeBytes32_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_device_encryption_key( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Notify this execution's chain adapter that a connection closed. - */ -open func notifyChainClosed(connectionId: UInt32) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_chain_closed( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId),uniffiCallStatus - ) -} -} - - /** - * Notify this execution's chain adapter of one JSON-RPC response. - */ -open func notifyChainResponse(connectionId: UInt32, json: String) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_chain_response( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId), - FfiConverterString.lower(json),uniffiCallStatus - ) -} -} - - /** - * Push a complete native Chat room-list replacement to this execution. - */ -open func notifyChatRoomsChanged(rooms: [ChatRoom]) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_chat_rooms_changed( - self.uniffiCloneHandle(), - FfiConverterSequenceTypeChatRoom.lower(rooms),uniffiCallStatus - ) -} -} - - /** - * Push a host locale replacement to this execution's subscriptions. - */ -open func notifyLocaleChanged(locale: HostLocaleSubscribeItem) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_locale_changed( - self.uniffiCloneHandle(), - FfiConverterTypeHostLocaleSubscribeItem_lower(locale),uniffiCallStatus - ) -} -} - - /** - * Push a preimage lookup replacement to this execution's subscriptions. - */ -open func notifyPreimageChanged(key: Data, value: Data?) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_preimage_changed( - self.uniffiCloneHandle(), - FfiConverterData.lower(key), - FfiConverterOptionData.lower(value),uniffiCallStatus - ) -} -} - - /** - * Push a host theme replacement to this execution's subscriptions. - */ -open func notifyThemeChanged(theme: HostThemeSubscribeItem) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_notify_theme_changed( - self.uniffiCloneHandle(), - FfiConverterTypeHostThemeSubscribeItem_lower(theme),uniffiCallStatus - ) -} -} - - /** - * Read a product-scoped permission authorization without prompting. - * - * A device capability resolves the host application's OS gate as well as - * storage, which means calling `device_permission_status` on the host. It - * is async for that reason: blocking a thread on a host callback - * deadlocks any implementation that hops to the same thread to answer. - */ -open func permissionAuthorizationStatus(request: PermissionAuthorizationRequest)async throws -> PermissionAuthorizationStatus { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_nativeproductexecution_permission_authorization_status( - self.uniffiCloneHandle(),FfiConverterTypePermissionAuthorizationRequest_lower(request) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_rust_buffer, - completeFunc: ffi_truapi_server_rust_future_complete_rust_buffer, - freeFunc: ffi_truapi_server_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypePermissionAuthorizationStatus_lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * Resolve a product's hard-subtree public key for hosts naming the account - * a review will sign with. Answers from the cache, the persisted slot, or - * the Account Holder, and `timeout_ms` bounds that wait. Exceeding it is - * an error; `None` means no active session. - */ -open func productSubtreePublicKey(productId: String, timeoutMs: UInt32?)throws -> Bytes32? { - return try FfiConverterOptionTypeBytes32.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_product_subtree_public_key( - self.uniffiCloneHandle(), - FfiConverterString.lower(productId), - FfiConverterOptionUInt32.lower(timeoutMs),uniffiCallStatus - ) -}) -} - - /** - * Publish one native Chat action, buffering it until the product - * connection subscribes. - */ -open func publishChatAction(action: HostChatActionSubscribeItem)throws {try rustCallWithError(FfiConverterTypeProductRuntimeError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_publish_chat_action( - self.uniffiCloneHandle(), - FfiConverterTypeHostChatActionSubscribeItem_lower(action),uniffiCallStatus - ) -} -} - - /** - * Request typed native UI for one stored custom Chat message. - */ -open func renderCustomMessage(messageId: String, messageType: String, payload: Data, observer: NativeCustomRendererObserver)throws -> NativeCustomRendererSubscription { - return try FfiConverterTypeNativeCustomRendererSubscription_lift(try rustCallWithError(FfiConverterTypeProductRuntimeError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_render_custom_message( - self.uniffiCloneHandle(), - FfiConverterString.lower(messageId), - FfiConverterString.lower(messageType), - FfiConverterData.lower(payload), - FfiConverterCallbackInterfaceNativeCustomRendererObserver_lower(observer),uniffiCallStatus - ) -}) -} - - /** - * Read the active session's X25519 chat identity private key, or `None` - * when no session is active. - */ -open func sessionChatIdentityKey()throws -> Bytes32? { - return try FfiConverterOptionTypeBytes32.lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_session_chat_identity_key( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Update a product-scoped permission authorization. - */ -open func setPermissionAuthorizationStatus(request: PermissionAuthorizationRequest, status: PermissionAuthorizationStatus)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_set_permission_authorization_status( - self.uniffiCloneHandle(), - FfiConverterTypePermissionAuthorizationRequest_lower(request), - FfiConverterTypePermissionAuthorizationStatus_lower(status),uniffiCallStatus - ) -} -} - - /** - * Permanently shut down this executable and all of its connection state. - * - * This is named `shutdown` rather than `close` because UniFFI Kotlin - * objects already implement `AutoCloseable.close()` for releasing the - * foreign object handle. - */ -open func shutdown() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_shutdown( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - /** - * Start this execution's independently authenticated localhost bridge. - */ -open func startWsBridge(bindPort: UInt16)throws -> WsBridgeEndpoint { - return try FfiConverterTypeWsBridgeEndpoint_lift(try rustCallWithError(FfiConverterTypeWsBridgeStartError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_start_ws_bridge( - self.uniffiCloneHandle(), - FfiConverterUInt16.lower(bindPort),uniffiCallStatus - ) -}) -} - - /** - * Stop the active bridge while leaving the execution reusable. - */ -open func stopWsBridge() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativeproductexecution_stop_ws_bridge( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - - -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeProductExecution: FfiConverter { - typealias FfiType = UInt64 - typealias SwiftType = NativeProductExecution - - public static func lift(_ handle: UInt64) throws -> NativeProductExecution { - return NativeProductExecution(unsafeFromHandle: handle) - } - - public static func lower(_ value: NativeProductExecution) -> UInt64 { - return value.uniffiCloneHandle() - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeProductExecution { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: NativeProductExecution, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeProductExecution_lift(_ handle: UInt64) throws -> NativeProductExecution { - return try FfiConverterTypeNativeProductExecution.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeProductExecution_lower(_ value: NativeProductExecution) -> UInt64 { - return FfiConverterTypeNativeProductExecution.lower(value) -} - - - - - - -/** - * Process-owned native TrUAPI runtime shared by all executable connections. - */ -public protocol NativeTrUApiHostRuntimeProtocol: AnyObject, Sendable { - - /** - * Activate or replace the process-wide local signing session. - */ - func activateLocalSession(secret: Data, liteUsername: String?) throws - - /** - * Core-owned logout for the process-wide authentication session. - */ - func disconnect() - - /** - * Answer one decrypted SSO remote message from a wallet-managed - * statement-store session. - * - * `message` is one SCALE-encoded `RemoteMessage` exactly as decrypted from - * the session statement. The bytes are deliberately opaque at this - * boundary: the wallet forwards wire encodings verbatim and never - * constructs them. Session control and transport stay with the wallet — - * `Disconnected` is reported, never handled here. Confirmation-gated - * requests await `confirm_user_action`, so this can take arbitrarily long. - */ - func handleSsoRequest(message: Data) async throws -> SsoRequestOutcome - - /** - * The most recent pass the in-process renewal loop ran. - * - * `None` until a pass has run, which is "not yet" rather than healthy. - * [`Self::start_statement_allowance_renewal`] has no return value, so a host - * driving the loop reads its result here: `slots_exhausted` on the last pass - * means a period filled up and an allowance went unrenewed, which is the one - * outcome retrying cannot fix and a person may need telling about. - */ - func lastStatementRenewalReport() -> StatementRenewalReport? - - /** - * The in-process loop's own cadence: at most an hour, tightening to land - * just after the next period boundary. - * - * The hourly cap is a retry rhythm, not a statement about when work is - * due. An allowance stays usable for `Resources.StmtStoreGraceWindow` past - * its boundary, 48 hours on `paseo-next-v2`, so a host scheduling one OS - * wake-up per period has ample slack and should treat any value under an - * hour as the boundary approaching, rather than requesting a wake every - * hour for a pass that will almost always report `AlreadyAllocated`. - */ - func nextStatementRenewalDelay() -> TimeInterval - - /** - * Notify the shared chain adapter that a connection closed. - */ - func notifyChainClosed(connectionId: UInt32) - - /** - * Notify the shared chain adapter of one JSON-RPC response. - */ - func notifyChainResponse(connectionId: UInt32, json: String) - - /** - * Open a connection-scoped execution with immutable trusted context. - * `chat_callbacks` installs the host's Chat adapter; hosts without the - * Chat modality pass `None`. - */ - func openProductExecution(callbacks: HostCallbacks, chatCallbacks: NativeChatCallbacks?, executionConfig: NativeProductExecutionConfig) throws -> NativeProductExecution - - /** - * Build the SCALE-encoded `Disconnected` message a wallet posts over a - * session it is ending. Each call carries a fresh opaque message id, - * like every outgoing SSO message; receivers detect disconnect by - * message variant, not id. Posting and record cleanup stay with the - * wallet. - */ - func prepareDisconnectRequest() -> Data - - /** - * Run one renewal pass now and report what each tracked target got. - * - * This is the entry point for hosts whose process cannot stay alive - * between periods: drive it from WorkManager or BGTaskScheduler rather - * than [`Self::start_statement_allowance_renewal`]. It submits extrinsics - * and blocks until they are included, so call it from a background thread. - * - * Needs an active session, which is the whole difficulty of the scheduled - * case: an OS-woken cold start has none until the host restores one, and - * the pass then fails with the bare reason `Disconnected`. Restore the - * session before calling, and treat that reason as "not ready" rather than - * as a renewal failure. [`Self::start_statement_allowance_renewal`] does - * not need this care; its loop skips a tick with no session and retries. - */ - func renewStatementAllowances() throws -> StatementRenewalReport - - /** - * Start the in-process renewal loop, for hosts that stay resident. Mobile - * hosts should schedule [`Self::renew_statement_allowances`] instead, - * because a suspended process stops ticking. Idempotent; the loop ends - * when this runtime is dropped. - */ - func startStatementAllowanceRenewal() - - /** - * Record the accounts a renewal pass should keep allowed. The ledger - * persists, so this only has to be called when the set changes, not on - * every launch. Renewal has nothing to do until at least one target is - * tracked. - */ - func trackStatementRenewalTargets(targets: [NativeStatementRenewalTarget]) throws - -} -/** - * Process-owned native TrUAPI runtime shared by all executable connections. - */ -open class NativeTrUApiHostRuntime: NativeTrUApiHostRuntimeProtocol, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_server_fn_clone_nativetruapihostruntime(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_server_fn_free_nativetruapihostruntime(handle, $0) } - } - - - /** - * Construct one host-level runtime and optionally activate its local session. - */ -public static func withRuntimeConfig(callbacks: HostCallbacks, runtimeConfig: NativeHostRuntimeConfig)throws -> NativeTrUApiHostRuntime { - return try FfiConverterTypeNativeTrUApiHostRuntime_lift(try rustCallWithError(FfiConverterTypeNativeRuntimeConfigError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_constructor_nativetruapihostruntime_with_runtime_config( - FfiConverterTypeHostCallbacks_lower(callbacks), - FfiConverterTypeNativeHostRuntimeConfig_lower(runtimeConfig),uniffiCallStatus - ) -}) -} - - - - /** - * Activate or replace the process-wide local signing session. - */ -open func activateLocalSession(secret: Data, liteUsername: String?)throws {try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_activate_local_session( - self.uniffiCloneHandle(), - FfiConverterData.lower(secret), - FfiConverterOptionString.lower(liteUsername),uniffiCallStatus - ) -} -} - - /** - * Core-owned logout for the process-wide authentication session. - */ -open func disconnect() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_disconnect( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - /** - * Answer one decrypted SSO remote message from a wallet-managed - * statement-store session. - * - * `message` is one SCALE-encoded `RemoteMessage` exactly as decrypted from - * the session statement. The bytes are deliberately opaque at this - * boundary: the wallet forwards wire encodings verbatim and never - * constructs them. Session control and transport stay with the wallet — - * `Disconnected` is reported, never handled here. Confirmation-gated - * requests await `confirm_user_action`, so this can take arbitrarily long. - */ -open func handleSsoRequest(message: Data)async throws -> SsoRequestOutcome { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_truapi_server_fn_method_nativetruapihostruntime_handle_sso_request( - self.uniffiCloneHandle(),FfiConverterData.lower(message) - ) - }, - pollFunc: ffi_truapi_server_rust_future_poll_rust_buffer, - completeFunc: ffi_truapi_server_rust_future_complete_rust_buffer, - freeFunc: ffi_truapi_server_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeSsoRequestOutcome_lift, - errorHandler: FfiConverterTypeHostRejection_lift - ) -} - - /** - * The most recent pass the in-process renewal loop ran. - * - * `None` until a pass has run, which is "not yet" rather than healthy. - * [`Self::start_statement_allowance_renewal`] has no return value, so a host - * driving the loop reads its result here: `slots_exhausted` on the last pass - * means a period filled up and an allowance went unrenewed, which is the one - * outcome retrying cannot fix and a person may need telling about. - */ -open func lastStatementRenewalReport() -> StatementRenewalReport? { - return try! FfiConverterOptionTypeStatementRenewalReport.lift(try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_last_statement_renewal_report( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * The in-process loop's own cadence: at most an hour, tightening to land - * just after the next period boundary. - * - * The hourly cap is a retry rhythm, not a statement about when work is - * due. An allowance stays usable for `Resources.StmtStoreGraceWindow` past - * its boundary, 48 hours on `paseo-next-v2`, so a host scheduling one OS - * wake-up per period has ample slack and should treat any value under an - * hour as the boundary approaching, rather than requesting a wake every - * hour for a pass that will almost always report `AlreadyAllocated`. - */ -open func nextStatementRenewalDelay() -> TimeInterval { - return try! FfiConverterDuration.lift(try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_next_statement_renewal_delay( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Notify the shared chain adapter that a connection closed. - */ -open func notifyChainClosed(connectionId: UInt32) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_notify_chain_closed( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId),uniffiCallStatus - ) -} -} - - /** - * Notify the shared chain adapter of one JSON-RPC response. - */ -open func notifyChainResponse(connectionId: UInt32, json: String) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_notify_chain_response( - self.uniffiCloneHandle(), - FfiConverterUInt32.lower(connectionId), - FfiConverterString.lower(json),uniffiCallStatus - ) -} -} - - /** - * Open a connection-scoped execution with immutable trusted context. - * `chat_callbacks` installs the host's Chat adapter; hosts without the - * Chat modality pass `None`. - */ -open func openProductExecution(callbacks: HostCallbacks, chatCallbacks: NativeChatCallbacks?, executionConfig: NativeProductExecutionConfig)throws -> NativeProductExecution { - return try FfiConverterTypeNativeProductExecution_lift(try rustCallWithError(FfiConverterTypeNativeRuntimeConfigError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_open_product_execution( - self.uniffiCloneHandle(), - FfiConverterTypeHostCallbacks_lower(callbacks), - FfiConverterOptionTypeNativeChatCallbacks.lower(chatCallbacks), - FfiConverterTypeNativeProductExecutionConfig_lower(executionConfig),uniffiCallStatus - ) -}) -} - - /** - * Build the SCALE-encoded `Disconnected` message a wallet posts over a - * session it is ending. Each call carries a fresh opaque message id, - * like every outgoing SSO message; receivers detect disconnect by - * message variant, not id. Posting and record cleanup stay with the - * wallet. - */ -open func prepareDisconnectRequest() -> Data { - return try! FfiConverterData.lift(try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_prepare_disconnect_request( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Run one renewal pass now and report what each tracked target got. - * - * This is the entry point for hosts whose process cannot stay alive - * between periods: drive it from WorkManager or BGTaskScheduler rather - * than [`Self::start_statement_allowance_renewal`]. It submits extrinsics - * and blocks until they are included, so call it from a background thread. - * - * Needs an active session, which is the whole difficulty of the scheduled - * case: an OS-woken cold start has none until the host restores one, and - * the pass then fails with the bare reason `Disconnected`. Restore the - * session before calling, and treat that reason as "not ready" rather than - * as a renewal failure. [`Self::start_statement_allowance_renewal`] does - * not need this care; its loop skips a tick with no session and retries. - */ -open func renewStatementAllowances()throws -> StatementRenewalReport { - return try FfiConverterTypeStatementRenewalReport_lift(try rustCallWithError(FfiConverterTypeHostRejection_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_renew_statement_allowances( - self.uniffiCloneHandle(),uniffiCallStatus - ) -}) -} - - /** - * Start the in-process renewal loop, for hosts that stay resident. Mobile - * hosts should schedule [`Self::renew_statement_allowances`] instead, - * because a suspended process stops ticking. Idempotent; the loop ends - * when this runtime is dropped. - */ -open func startStatementAllowanceRenewal() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_start_statement_allowance_renewal( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - /** - * Record the accounts a renewal pass should keep allowed. The ledger - * persists, so this only has to be called when the set changes, not on - * every launch. Renewal has nothing to do until at least one target is - * tracked. - */ -open func trackStatementRenewalTargets(targets: [NativeStatementRenewalTarget])throws {try rustCallWithError(FfiConverterTypeNativeRenewalTargetError_lift) { - uniffiCallStatus in - uniffi_truapi_server_fn_method_nativetruapihostruntime_track_statement_renewal_targets( - self.uniffiCloneHandle(), - FfiConverterSequenceTypeNativeStatementRenewalTarget.lower(targets),uniffiCallStatus - ) -} -} - - - -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeTrUApiHostRuntime: FfiConverter { - typealias FfiType = UInt64 - typealias SwiftType = NativeTrUApiHostRuntime - - public static func lift(_ handle: UInt64) throws -> NativeTrUApiHostRuntime { - return NativeTrUApiHostRuntime(unsafeFromHandle: handle) - } - - public static func lower(_ value: NativeTrUApiHostRuntime) -> UInt64 { - return value.uniffiCloneHandle() - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeTrUApiHostRuntime { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: NativeTrUApiHostRuntime, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeTrUApiHostRuntime_lift(_ handle: UInt64) throws -> NativeTrUApiHostRuntime { - return try FfiConverterTypeNativeTrUApiHostRuntime.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeTrUApiHostRuntime_lower(_ value: NativeTrUApiHostRuntime) -> UInt64 { - return FfiConverterTypeNativeTrUApiHostRuntime.lower(value) -} - - - - -/** - * Process-owned native host configuration shared by every product execution. - */ -public struct NativeHostRuntimeConfig: Equatable, Hashable { - /** - * Host name shown by the wallet during SSO pairing. - */ - public var hostName: String - /** - * Optional host icon URL shown by the wallet during SSO pairing. - */ - public var hostIcon: String? - /** - * Optional host version shown by the wallet during SSO pairing. - */ - public var hostVersion: String? - /** - * Platform category this host runs on, reported to products via - * `System::host_info`. - */ - public var hostPlatform: HostPlatform - /** - * Optional platform/browser name shown by the wallet during SSO pairing. - */ - public var platformType: String? - /** - * Optional platform/browser version shown by the wallet during SSO pairing. - */ - public var platformVersion: String? - /** - * People-chain genesis hash. Must be exactly 32 bytes. - */ - public var peopleChainGenesisHash: Data - /** - * Bulletin-chain genesis hash. Must be exactly 32 bytes. - */ - public var bulletinChainGenesisHash: Data - /** - * Optional local signing-host secret material (raw BIP-39 entropy). - */ - public var localSessionSecret: Data? - /** - * Optional lite username attached to the local signing-host session. - */ - public var localSessionLiteUsername: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Host name shown by the wallet during SSO pairing. - */hostName: String, - /** - * Optional host icon URL shown by the wallet during SSO pairing. - */hostIcon: String?, - /** - * Optional host version shown by the wallet during SSO pairing. - */hostVersion: String?, - /** - * Platform category this host runs on, reported to products via - * `System::host_info`. - */hostPlatform: HostPlatform, - /** - * Optional platform/browser name shown by the wallet during SSO pairing. - */platformType: String?, - /** - * Optional platform/browser version shown by the wallet during SSO pairing. - */platformVersion: String?, - /** - * People-chain genesis hash. Must be exactly 32 bytes. - */peopleChainGenesisHash: Data, - /** - * Bulletin-chain genesis hash. Must be exactly 32 bytes. - */bulletinChainGenesisHash: Data, - /** - * Optional local signing-host secret material (raw BIP-39 entropy). - */localSessionSecret: Data?, - /** - * Optional lite username attached to the local signing-host session. - */localSessionLiteUsername: String?) { - self.hostName = hostName - self.hostIcon = hostIcon - self.hostVersion = hostVersion - self.hostPlatform = hostPlatform - self.platformType = platformType - self.platformVersion = platformVersion - self.peopleChainGenesisHash = peopleChainGenesisHash - self.bulletinChainGenesisHash = bulletinChainGenesisHash - self.localSessionSecret = localSessionSecret - self.localSessionLiteUsername = localSessionLiteUsername - } - - - - -} - -#if compiler(>=6) -extension NativeHostRuntimeConfig: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeHostRuntimeConfig: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeHostRuntimeConfig { - return - try NativeHostRuntimeConfig( - hostName: FfiConverterString.read(from: &buf), - hostIcon: FfiConverterOptionString.read(from: &buf), - hostVersion: FfiConverterOptionString.read(from: &buf), - hostPlatform: FfiConverterTypeHostPlatform.read(from: &buf), - platformType: FfiConverterOptionString.read(from: &buf), - platformVersion: FfiConverterOptionString.read(from: &buf), - peopleChainGenesisHash: FfiConverterData.read(from: &buf), - bulletinChainGenesisHash: FfiConverterData.read(from: &buf), - localSessionSecret: FfiConverterOptionData.read(from: &buf), - localSessionLiteUsername: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: NativeHostRuntimeConfig, into buf: inout [UInt8]) { - FfiConverterString.write(value.hostName, into: &buf) - FfiConverterOptionString.write(value.hostIcon, into: &buf) - FfiConverterOptionString.write(value.hostVersion, into: &buf) - FfiConverterTypeHostPlatform.write(value.hostPlatform, into: &buf) - FfiConverterOptionString.write(value.platformType, into: &buf) - FfiConverterOptionString.write(value.platformVersion, into: &buf) - FfiConverterData.write(value.peopleChainGenesisHash, into: &buf) - FfiConverterData.write(value.bulletinChainGenesisHash, into: &buf) - FfiConverterOptionData.write(value.localSessionSecret, into: &buf) - FfiConverterOptionString.write(value.localSessionLiteUsername, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeHostRuntimeConfig_lift(_ buf: RustBuffer) throws -> NativeHostRuntimeConfig { - return try FfiConverterTypeNativeHostRuntimeConfig.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeHostRuntimeConfig_lower(_ value: NativeHostRuntimeConfig) -> RustBuffer { - return FfiConverterTypeNativeHostRuntimeConfig.lower(value) -} - - -/** - * Trusted identity attached by a native host to one executable connection. - */ -public struct NativeProductExecutionConfig: Equatable, Hashable { - /** - * Canonical product identifier used for policy, storage, and derivation. - */ - public var productId: String - /** - * Trusted executable kind selected before product code starts. - */ - public var executionKind: ProductExecutionKind - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Canonical product identifier used for policy, storage, and derivation. - */productId: String, - /** - * Trusted executable kind selected before product code starts. - */executionKind: ProductExecutionKind) { - self.productId = productId - self.executionKind = executionKind - } - - - - -} - -#if compiler(>=6) -extension NativeProductExecutionConfig: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeProductExecutionConfig: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeProductExecutionConfig { - return - try NativeProductExecutionConfig( - productId: FfiConverterString.read(from: &buf), - executionKind: FfiConverterTypeProductExecutionKind.read(from: &buf) - ) - } - - public static func write(_ value: NativeProductExecutionConfig, into buf: inout [UInt8]) { - FfiConverterString.write(value.productId, into: &buf) - FfiConverterTypeProductExecutionKind.write(value.executionKind, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeProductExecutionConfig_lift(_ buf: RustBuffer) throws -> NativeProductExecutionConfig { - return try FfiConverterTypeNativeProductExecutionConfig.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeProductExecutionConfig_lower(_ value: NativeProductExecutionConfig) -> RustBuffer { - return FfiConverterTypeNativeProductExecutionConfig.lower(value) -} - - -/** - * What one target's renewal produced, paired with the label that identifies it - * in the ledger. - */ -public struct StatementRenewalOutcome: Equatable, Hashable { - /** - * Ledger label for the renewed target. - */ - public var label: String - /** - * What the pass did for this target. - */ - public var status: TargetRenewalStatus - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Ledger label for the renewed target. - */label: String, - /** - * What the pass did for this target. - */status: TargetRenewalStatus) { - self.label = label - self.status = status - } - - - - -} - -#if compiler(>=6) -extension StatementRenewalOutcome: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeStatementRenewalOutcome: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StatementRenewalOutcome { - return - try StatementRenewalOutcome( - label: FfiConverterString.read(from: &buf), - status: FfiConverterTypeTargetRenewalStatus.read(from: &buf) - ) - } - - public static func write(_ value: StatementRenewalOutcome, into buf: inout [UInt8]) { - FfiConverterString.write(value.label, into: &buf) - FfiConverterTypeTargetRenewalStatus.write(value.status, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementRenewalOutcome_lift(_ buf: RustBuffer) throws -> StatementRenewalOutcome { - return try FfiConverterTypeStatementRenewalOutcome.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementRenewalOutcome_lower(_ value: StatementRenewalOutcome) -> RustBuffer { - return FfiConverterTypeStatementRenewalOutcome.lower(value) -} - - -/** - * Summary of one renewal pass. - */ -public struct StatementRenewalReport: Equatable, Hashable { - /** - * Period the pass registered for. - */ - public var period: UInt32 - /** - * Per-target outcomes in ledger order. - */ - public var outcomes: [StatementRenewalOutcome] - /** - * Labels of targets this pass dropped because a different identity - * promised them. - * - * Dropping is silent otherwise: a pruned target simply stops appearing in - * `outcomes`, and the surface has no way to list the ledger, so a host - * could only infer it from an absence. A raw account target does not - * survive a change of root entropy, so this is how a host learns to - * re-track one. - */ - public var pruned: [String] - /** - * Whether the pass hit slot exhaustion for this period. - */ - public var slotsExhausted: Bool - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Period the pass registered for. - */period: UInt32, - /** - * Per-target outcomes in ledger order. - */outcomes: [StatementRenewalOutcome], - /** - * Labels of targets this pass dropped because a different identity - * promised them. - * - * Dropping is silent otherwise: a pruned target simply stops appearing in - * `outcomes`, and the surface has no way to list the ledger, so a host - * could only infer it from an absence. A raw account target does not - * survive a change of root entropy, so this is how a host learns to - * re-track one. - */pruned: [String], - /** - * Whether the pass hit slot exhaustion for this period. - */slotsExhausted: Bool) { - self.period = period - self.outcomes = outcomes - self.pruned = pruned - self.slotsExhausted = slotsExhausted - } - - - - -} - -#if compiler(>=6) -extension StatementRenewalReport: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeStatementRenewalReport: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StatementRenewalReport { - return - try StatementRenewalReport( - period: FfiConverterUInt32.read(from: &buf), - outcomes: FfiConverterSequenceTypeStatementRenewalOutcome.read(from: &buf), - pruned: FfiConverterSequenceString.read(from: &buf), - slotsExhausted: FfiConverterBool.read(from: &buf) - ) - } - - public static func write(_ value: StatementRenewalReport, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.period, into: &buf) - FfiConverterSequenceTypeStatementRenewalOutcome.write(value.outcomes, into: &buf) - FfiConverterSequenceString.write(value.pruned, into: &buf) - FfiConverterBool.write(value.slotsExhausted, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementRenewalReport_lift(_ buf: RustBuffer) throws -> StatementRenewalReport { - return try FfiConverterTypeStatementRenewalReport.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeStatementRenewalReport_lower(_ value: StatementRenewalReport) -> RustBuffer { - return FfiConverterTypeStatementRenewalReport.lower(value) -} - - -/** - * Per-session descriptor returned to the host: product uses `port + token` - * to build its WebSocket URL (e.g. `ws://127.0.0.1:/?t=`). - */ -public struct WsBridgeEndpoint: Equatable, Hashable { - /** - * Localhost port the bridge is listening on. - */ - public var port: UInt16 - /** - * Session token; the connecting client must supply this as the - * `?t=` query parameter to be accepted. - */ - public var token: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Localhost port the bridge is listening on. - */port: UInt16, - /** - * Session token; the connecting client must supply this as the - * `?t=` query parameter to be accepted. - */token: String) { - self.port = port - self.token = token - } - - - - -} - -#if compiler(>=6) -extension WsBridgeEndpoint: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeWsBridgeEndpoint: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WsBridgeEndpoint { - return - try WsBridgeEndpoint( - port: FfiConverterUInt16.read(from: &buf), - token: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: WsBridgeEndpoint, into buf: inout [UInt8]) { - FfiConverterUInt16.write(value.port, into: &buf) - FfiConverterString.write(value.token, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWsBridgeEndpoint_lift(_ buf: RustBuffer) throws -> WsBridgeEndpoint { - return try FfiConverterTypeWsBridgeEndpoint.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWsBridgeEndpoint_lower(_ value: WsBridgeEndpoint) -> RustBuffer { - return FfiConverterTypeWsBridgeEndpoint.lower(value) -} - - -/** - * Host-thrown navigation failure wrapping the canonical error payload. - * - * As described for [`HostStorageError`], [UniFFI's supported error - * representations](https://mozilla.github.io/uniffi-rs/0.32/types/errors.html) - * do not provide a derive-based way to bridge namespace-specific Kotlin - * `RustBuffer` types when an external error is thrown by a foreign-trait - * callback. The one-variant wrapper avoids mirroring the canonical navigation - * error enum locally. - */ -public -enum HostNavigateRejection: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * Canonical navigation failure payload. - */ - case Navigate(HostNavigateToError - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension HostNavigateRejection: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostNavigateRejection: FfiConverterRustBuffer { - typealias SwiftType = HostNavigateRejection - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostNavigateRejection { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .Navigate( - try FfiConverterTypeHostNavigateToError.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostNavigateRejection, into buf: inout [UInt8]) { - switch value { - - - - - - case let .Navigate(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeHostNavigateToError.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostNavigateRejection_lift(_ buf: RustBuffer) throws -> HostNavigateRejection { - return try FfiConverterTypeHostNavigateRejection.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostNavigateRejection_lower(_ value: HostNavigateRejection) -> RustBuffer { - return FfiConverterTypeHostNavigateRejection.lower(value) -} - - -/** - * Native-friendly rejection error returned by callback methods that map onto - * [`truapi::v01::GenericError`]. - * - * [`uniffi::Error` is the value-style error mapping and only supports enums; - * UniFFI's struct alternative is an `Arc`-backed object - * error](https://mozilla.github.io/uniffi-rs/0.32/types/errors.html). Making the - * canonical SCALE value an object would require Rust-owned handles and foreign - * construction solely to carry one string. This local enum keeps the native - * exception value-like without changing the canonical wire representation. - */ -public -enum HostRejection: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * Caller rejected the operation. - */ - case Rejected( - /** - * Human-readable rejection reason. - */reason: String - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension HostRejection: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostRejection: FfiConverterRustBuffer { - typealias SwiftType = HostRejection - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostRejection { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .Rejected( - reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostRejection, into buf: inout [UInt8]) { - switch value { - - - - - - case let .Rejected(reason): - writeInt(&buf, Int32(1)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostRejection_lift(_ buf: RustBuffer) throws -> HostRejection { - return try FfiConverterTypeHostRejection.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostRejection_lower(_ value: HostRejection) -> RustBuffer { - return FfiConverterTypeHostRejection.lower(value) -} - - -/** - * Host-thrown storage failure wrapping the canonical error payload, so its - * variants remain defined once in `truapi`. - * - * [UniFFI 0.32 exposes `Result` failures as error enums or `Arc`-backed error - * objects](https://mozilla.github.io/uniffi-rs/0.32/types/errors.html). Although - * the canonical enum can be exposed as an external error, Kotlin foreign-trait - * callbacks must lower thrown errors into this namespace's `RustBuffer`; the - * external converter returns the canonical namespace's distinct `RustBuffer` - * type. There is no derive-based bridge between them. `uniffi::remote(Error)` - * would instead duplicate every canonical variant and field, so this local - * one-variant wrapper preserves the canonical definition. - */ -public -enum HostStorageError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * Canonical storage failure payload. - */ - case Storage(HostLocalStorageReadError - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension HostStorageError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHostStorageError: FfiConverterRustBuffer { - typealias SwiftType = HostStorageError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HostStorageError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .Storage( - try FfiConverterTypeHostLocalStorageReadError.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HostStorageError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .Storage(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeHostLocalStorageReadError.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostStorageError_lift(_ buf: RustBuffer) throws -> HostStorageError { - return try FfiConverterTypeHostStorageError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeHostStorageError_lower(_ value: HostStorageError) -> RustBuffer { - return FfiConverterTypeHostStorageError.lower(value) -} - - -/** - * OS status of a device capability, as a native host reports it. - * - * Mirrors [`truapi_platform::DevicePermissionStatus`], which cannot be used - * directly: an async callback method returning a type from another UniFFI - * namespace lowers into that namespace's `RustBuffer`, and the generated - * Kotlin then fails to compile. The conversion is total. - */ - -public enum NativeDevicePermissionStatus: Equatable, Hashable { - - /** - * The OS grants this capability to the host application. - */ - case granted - /** - * The OS refuses it; only system settings can change that. - */ - case denied - /** - * The OS has not been asked, or reset its own answer. - */ - case notDetermined - /** - * This platform has no OS gate for the capability. - */ - case notApplicable - - - - - -} - -#if compiler(>=6) -extension NativeDevicePermissionStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeDevicePermissionStatus: FfiConverterRustBuffer { - typealias SwiftType = NativeDevicePermissionStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeDevicePermissionStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .granted - - case 2: return .denied - - case 3: return .notDetermined - - case 4: return .notApplicable - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: NativeDevicePermissionStatus, into buf: inout [UInt8]) { - switch value { - - - case .granted: - writeInt(&buf, Int32(1)) - - - case .denied: - writeInt(&buf, Int32(2)) - - - case .notDetermined: - writeInt(&buf, Int32(3)) - - - case .notApplicable: - writeInt(&buf, Int32(4)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeDevicePermissionStatus_lift(_ buf: RustBuffer) throws -> NativeDevicePermissionStatus { - return try FfiConverterTypeNativeDevicePermissionStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeDevicePermissionStatus_lower(_ value: NativeDevicePermissionStatus) -> RustBuffer { - return FfiConverterTypeNativeDevicePermissionStatus.lower(value) -} - - - -/** - * Rejected renewal-target registration. - */ -public -enum NativeRenewalTargetError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * `account_id` was not exactly 32 bytes. - */ - case InvalidAccountId( - /** - * Supplied byte length. - */actual: UInt64 - ) - /** - * `product_id` is not a usable product identifier. - */ - case InvalidProductId( - /** - * The identifier as supplied. - */productId: String - ) - /** - * The core refused to record the targets. - */ - case Rejected( - /** - * Human-readable rejection reason. - */reason: String - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension NativeRenewalTargetError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeRenewalTargetError: FfiConverterRustBuffer { - typealias SwiftType = NativeRenewalTargetError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeRenewalTargetError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .InvalidAccountId( - actual: try FfiConverterUInt64.read(from: &buf) - ) - case 2: return .InvalidProductId( - productId: try FfiConverterString.read(from: &buf) - ) - case 3: return .Rejected( - reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: NativeRenewalTargetError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .InvalidAccountId(actual): - writeInt(&buf, Int32(1)) - FfiConverterUInt64.write(actual, into: &buf) - - - case let .InvalidProductId(productId): - writeInt(&buf, Int32(2)) - FfiConverterString.write(productId, into: &buf) - - - case let .Rejected(reason): - writeInt(&buf, Int32(3)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeRenewalTargetError_lift(_ buf: RustBuffer) throws -> NativeRenewalTargetError { - return try FfiConverterTypeNativeRenewalTargetError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeRenewalTargetError_lower(_ value: NativeRenewalTargetError) -> RustBuffer { - return FfiConverterTypeNativeRenewalTargetError.lower(value) -} - - -/** - * Native runtime config validation error. - */ -public -enum NativeRuntimeConfigError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * Required string field was empty or whitespace-only. - */ - case EmptyField( - /** - * Field name. - */field: String - ) - /** - * People-chain genesis hash was not exactly 32 bytes. - */ - case InvalidPeopleChainGenesisHash( - /** - * Supplied byte length. - */actual: UInt64 - ) - /** - * Bulletin-chain genesis hash was not exactly 32 bytes. - */ - case InvalidBulletinChainGenesisHash( - /** - * Supplied byte length. - */actual: UInt64 - ) - /** - * Host icon URL could not be parsed. - */ - case InvalidHostIcon( - /** - * Parse failure reason. - */reason: String - ) - /** - * Host icon URL used a non-HTTPS scheme. - */ - case InsecureHostIcon( - /** - * Actual URL scheme. - */scheme: String - ) - /** - * Pairing deeplink scheme included a URL separator. - */ - case InvalidDeeplinkScheme( - /** - * Actual deeplink scheme value. - */scheme: String - ) - /** - * Product id was not a valid host-spec product identifier. - */ - case InvalidProductId( - /** - * Actual product id value. - */productId: String - ) - /** - * Local signing-host session activation failed. - */ - case LocalSessionActivation( - /** - * Activation failure reason. - */reason: String - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension NativeRuntimeConfigError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeRuntimeConfigError: FfiConverterRustBuffer { - typealias SwiftType = NativeRuntimeConfigError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeRuntimeConfigError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .EmptyField( - field: try FfiConverterString.read(from: &buf) - ) - case 2: return .InvalidPeopleChainGenesisHash( - actual: try FfiConverterUInt64.read(from: &buf) - ) - case 3: return .InvalidBulletinChainGenesisHash( - actual: try FfiConverterUInt64.read(from: &buf) - ) - case 4: return .InvalidHostIcon( - reason: try FfiConverterString.read(from: &buf) - ) - case 5: return .InsecureHostIcon( - scheme: try FfiConverterString.read(from: &buf) - ) - case 6: return .InvalidDeeplinkScheme( - scheme: try FfiConverterString.read(from: &buf) - ) - case 7: return .InvalidProductId( - productId: try FfiConverterString.read(from: &buf) - ) - case 8: return .LocalSessionActivation( - reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: NativeRuntimeConfigError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .EmptyField(field): - writeInt(&buf, Int32(1)) - FfiConverterString.write(field, into: &buf) - - - case let .InvalidPeopleChainGenesisHash(actual): - writeInt(&buf, Int32(2)) - FfiConverterUInt64.write(actual, into: &buf) - - - case let .InvalidBulletinChainGenesisHash(actual): - writeInt(&buf, Int32(3)) - FfiConverterUInt64.write(actual, into: &buf) - - - case let .InvalidHostIcon(reason): - writeInt(&buf, Int32(4)) - FfiConverterString.write(reason, into: &buf) - - - case let .InsecureHostIcon(scheme): - writeInt(&buf, Int32(5)) - FfiConverterString.write(scheme, into: &buf) - - - case let .InvalidDeeplinkScheme(scheme): - writeInt(&buf, Int32(6)) - FfiConverterString.write(scheme, into: &buf) - - - case let .InvalidProductId(productId): - writeInt(&buf, Int32(7)) - FfiConverterString.write(productId, into: &buf) - - - case let .LocalSessionActivation(reason): - writeInt(&buf, Int32(8)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeRuntimeConfigError_lift(_ buf: RustBuffer) throws -> NativeRuntimeConfigError { - return try FfiConverterTypeNativeRuntimeConfigError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeRuntimeConfigError_lower(_ value: NativeRuntimeConfigError) -> RustBuffer { - return FfiConverterTypeNativeRuntimeConfigError.lower(value) -} - - -/** - * An account the host wants kept allowed on the Statement Store across - * periods. Mirrors [`crate::runtime::StatementRenewalTarget`] with a - * length-checked `account_id`, because UniFFI carries byte arrays as `Vec` - * rather than a fixed width. - */ - -public enum NativeStatementRenewalTarget: Equatable, Hashable { - - /** - * The statement-store allowance account derived for one product. - */ - case productStatementAllowance( - /** - * Product the allowance account belongs to. - */productId: String - ) - /** - * The wallet's own SSO account. - */ - case walletSso - /** - * A fixed account, such as a pairing peer's device statement key. - */ - case account( - /** - * Account to keep allowed; exactly 32 bytes. - */accountId: Data, - /** - * Human-readable name used in logs and reports. - */label: String - ) - - - - - -} - -#if compiler(>=6) -extension NativeStatementRenewalTarget: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNativeStatementRenewalTarget: FfiConverterRustBuffer { - typealias SwiftType = NativeStatementRenewalTarget - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeStatementRenewalTarget { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .productStatementAllowance(productId: try FfiConverterString.read(from: &buf) - ) - - case 2: return .walletSso - - case 3: return .account(accountId: try FfiConverterData.read(from: &buf), label: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: NativeStatementRenewalTarget, into buf: inout [UInt8]) { - switch value { - - - case let .productStatementAllowance(productId): - writeInt(&buf, Int32(1)) - FfiConverterString.write(productId, into: &buf) - - - case .walletSso: - writeInt(&buf, Int32(2)) - - - case let .account(accountId,label): - writeInt(&buf, Int32(3)) - FfiConverterData.write(accountId, into: &buf) - FfiConverterString.write(label, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeStatementRenewalTarget_lift(_ buf: RustBuffer) throws -> NativeStatementRenewalTarget { - return try FfiConverterTypeNativeStatementRenewalTarget.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNativeStatementRenewalTarget_lower(_ value: NativeStatementRenewalTarget) -> RustBuffer { - return FfiConverterTypeNativeStatementRenewalTarget.lower(value) -} - - - -/** - * How the input URL should be opened. Kept in one enum rather than passing - * a raw string so the dispatcher can reject invalid input before reaching - * any platform callback. The open variants carry the ready-to-load canonical - * URL; `DotName` and `Localhost` keep the dotns/localhost identity visible so - * env-aware hosts can rewrite dotNS names for their active environment and - * re-parse without losing information. - */ - -public enum NavigateDecision: Equatable, Hashable { - - /** - * A dotNS identifier plus path/query/hash suffix (no leading `/`). - */ - case dotName( - /** - * Lower-cased dotNS host (e.g. `mytestapp.dot`). - */identifier: String, - /** - * Path/query/hash suffix without a leading `/`. - */path: String, - /** - * Loadable `https://` URL for this decision. - */canonicalUrl: String - ) - /** - * A `localhost[:port]` URL plus path/query/hash suffix (no leading `/`). - */ - case localhost( - /** - * `localhost` with optional `:port` suffix. - */host: String, - /** - * Path/query/hash suffix without a leading `/`. - */path: String, - /** - * Loadable `http://` URL for this decision. - */canonicalUrl: String - ) - /** - * An absolute external URL with an `http(s):` scheme prepended if missing. - */ - case external( - /** - * Canonical URL string. - */url: String - ) - /** - * Input that fails every branch: empty, unparseable, or a dotNS URL - * carrying port/userinfo (both forbidden since dotns resolves via the - * chain and has no notion of either). - */ - case reject( - /** - * Human-readable reason for the rejection. - */reason: String - ) - - - - - -} - -#if compiler(>=6) -extension NavigateDecision: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeNavigateDecision: FfiConverterRustBuffer { - typealias SwiftType = NavigateDecision - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NavigateDecision { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .dotName(identifier: try FfiConverterString.read(from: &buf), path: try FfiConverterString.read(from: &buf), canonicalUrl: try FfiConverterString.read(from: &buf) - ) - - case 2: return .localhost(host: try FfiConverterString.read(from: &buf), path: try FfiConverterString.read(from: &buf), canonicalUrl: try FfiConverterString.read(from: &buf) - ) - - case 3: return .external(url: try FfiConverterString.read(from: &buf) - ) - - case 4: return .reject(reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: NavigateDecision, into buf: inout [UInt8]) { - switch value { - - - case let .dotName(identifier,path,canonicalUrl): - writeInt(&buf, Int32(1)) - FfiConverterString.write(identifier, into: &buf) - FfiConverterString.write(path, into: &buf) - FfiConverterString.write(canonicalUrl, into: &buf) - - - case let .localhost(host,path,canonicalUrl): - writeInt(&buf, Int32(2)) - FfiConverterString.write(host, into: &buf) - FfiConverterString.write(path, into: &buf) - FfiConverterString.write(canonicalUrl, into: &buf) - - - case let .external(url): - writeInt(&buf, Int32(3)) - FfiConverterString.write(url, into: &buf) - - - case let .reject(reason): - writeInt(&buf, Int32(4)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNavigateDecision_lift(_ buf: RustBuffer) throws -> NavigateDecision { - return try FfiConverterTypeNavigateDecision.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeNavigateDecision_lower(_ value: NavigateDecision) -> RustBuffer { - return FfiConverterTypeNavigateDecision.lower(value) -} - - - -/** - * Errors returned while routing work through a product runtime. - */ -public -enum ProductRuntimeError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * No connected product runtime is available. - */ - case NotConnected - /** - * Incoming bytes did not decode as a protocol frame. - */ - case InvalidFrame( - /** - * Decode failure reason. - */reason: String - ) - /** - * The connection execution kind does not allow the operation. - */ - case Denied - /** - * The product connection has already closed. - */ - case Closed - /** - * The product or native host did not install the requested surface. - */ - case Unsupported - /** - * The bounded pre-subscription action queue is full. - */ - case BufferFull - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension ProductRuntimeError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeProductRuntimeError: FfiConverterRustBuffer { - typealias SwiftType = ProductRuntimeError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProductRuntimeError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .NotConnected - case 2: return .InvalidFrame( - reason: try FfiConverterString.read(from: &buf) - ) - case 3: return .Denied - case 4: return .Closed - case 5: return .Unsupported - case 6: return .BufferFull - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ProductRuntimeError, into buf: inout [UInt8]) { - switch value { - - - - - - case .NotConnected: - writeInt(&buf, Int32(1)) - - - case let .InvalidFrame(reason): - writeInt(&buf, Int32(2)) - FfiConverterString.write(reason, into: &buf) - - - case .Denied: - writeInt(&buf, Int32(3)) - - - case .Closed: - writeInt(&buf, Int32(4)) - - - case .Unsupported: - writeInt(&buf, Int32(5)) - - - case .BufferFull: - writeInt(&buf, Int32(6)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductRuntimeError_lift(_ buf: RustBuffer) throws -> ProductRuntimeError { - return try FfiConverterTypeProductRuntimeError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeProductRuntimeError_lower(_ value: ProductRuntimeError) -> RustBuffer { - return FfiConverterTypeProductRuntimeError.lower(value) -} - - -/** - * FFI projection of the canonical - * [`SsoRequestOutcome`](crate::host_logic::sso::messages::SsoRequestOutcome), - * concrete because UniFFI cannot export generics. - * - * Variants carry SCALE-encoded wire bytes rather than decoded Rust types because - * the wallet forwards encodings verbatim and never constructs them — the opaque - * bytes are the correct boundary representation here. - */ - -public enum SsoRequestOutcome: Equatable, Hashable { - - /** - * SCALE-encoded response to post back over the session. - */ - case response( - /** - * SCALE-encoded `RemoteMessage` response ready to submit over the - * session statement store. - */message: Data - ) - /** - * The peer ended the session; the wallet tears down its transport and - * records (host entry, device record, device-removed broadcast). - */ - case disconnected - /** - * Not a request; nothing to post. - */ - case ignored - - - - - -} - -#if compiler(>=6) -extension SsoRequestOutcome: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSsoRequestOutcome: FfiConverterRustBuffer { - typealias SwiftType = SsoRequestOutcome - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SsoRequestOutcome { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .response(message: try FfiConverterData.read(from: &buf) - ) - - case 2: return .disconnected - - case 3: return .ignored - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SsoRequestOutcome, into buf: inout [UInt8]) { - switch value { - - - case let .response(message): - writeInt(&buf, Int32(1)) - FfiConverterData.write(message, into: &buf) - - - case .disconnected: - writeInt(&buf, Int32(2)) - - - case .ignored: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSsoRequestOutcome_lift(_ buf: RustBuffer) throws -> SsoRequestOutcome { - return try FfiConverterTypeSsoRequestOutcome.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSsoRequestOutcome_lower(_ value: SsoRequestOutcome) -> RustBuffer { - return FfiConverterTypeSsoRequestOutcome.lower(value) -} - - - -/** - * Outcome of renewing one target. - */ - -public enum TargetRenewalStatus: Equatable, Hashable { - - /** - * The extrinsic reached a block; the target holds `seq` this period. - */ - case registered( - /** - * Claimed slot sequence. - */seq: UInt32, - /** - * Block hash the extrinsic landed in. - */blockHash: String - ) - /** - * The target already held a slot this period; nothing submitted. - */ - case alreadyAllocated( - /** - * Existing slot sequence. - */seq: UInt32 - ) - /** - * Registration failed; the target is retried on the next tick. - */ - case failed( - /** - * Failure detail. - */reason: String - ) - /** - * Not attempted: the host ran out of slots earlier in the pass. - */ - case skippedExhausted - - - - - -} - -#if compiler(>=6) -extension TargetRenewalStatus: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTargetRenewalStatus: FfiConverterRustBuffer { - typealias SwiftType = TargetRenewalStatus - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TargetRenewalStatus { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .registered(seq: try FfiConverterUInt32.read(from: &buf), blockHash: try FfiConverterString.read(from: &buf) - ) - - case 2: return .alreadyAllocated(seq: try FfiConverterUInt32.read(from: &buf) - ) - - case 3: return .failed(reason: try FfiConverterString.read(from: &buf) - ) - - case 4: return .skippedExhausted - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TargetRenewalStatus, into buf: inout [UInt8]) { - switch value { - - - case let .registered(seq,blockHash): - writeInt(&buf, Int32(1)) - FfiConverterUInt32.write(seq, into: &buf) - FfiConverterString.write(blockHash, into: &buf) - - - case let .alreadyAllocated(seq): - writeInt(&buf, Int32(2)) - FfiConverterUInt32.write(seq, into: &buf) - - - case let .failed(reason): - writeInt(&buf, Int32(3)) - FfiConverterString.write(reason, into: &buf) - - - case .skippedExhausted: - writeInt(&buf, Int32(4)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTargetRenewalStatus_lift(_ buf: RustBuffer) throws -> TargetRenewalStatus { - return try FfiConverterTypeTargetRenewalStatus.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTargetRenewalStatus_lower(_ value: TargetRenewalStatus) -> RustBuffer { - return FfiConverterTypeTargetRenewalStatus.lower(value) -} - - - -/** - * Failure modes returned from host-facing `start_ws_bridge` wrappers. - */ -public -enum WsBridgeStartError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * A bridge is already running for this host. - */ - case AlreadyRunning(message: String) - - /** - * Anything else (bind failure, runtime spin-up failure, ...). - */ - case Io(message: String) - - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension WsBridgeStartError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeWsBridgeStartError: FfiConverterRustBuffer { - typealias SwiftType = WsBridgeStartError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WsBridgeStartError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .AlreadyRunning( - message: try FfiConverterString.read(from: &buf) - ) - - case 2: return .Io( - message: try FfiConverterString.read(from: &buf) - ) - - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: WsBridgeStartError, into buf: inout [UInt8]) { - switch value { - - - - - case .AlreadyRunning(_ /* message is ignored*/): - writeInt(&buf, Int32(1)) - case .Io(_ /* message is ignored*/): - writeInt(&buf, Int32(2)) - - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWsBridgeStartError_lift(_ buf: RustBuffer) throws -> WsBridgeStartError { - return try FfiConverterTypeWsBridgeStartError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWsBridgeStartError_lower(_ value: WsBridgeStartError) -> RustBuffer { - return FfiConverterTypeWsBridgeStartError.lower(value) -} - - - - -/** - * Observer implemented by a native host to receive renderer tree replacements. - */ -public protocol NativeCustomRendererObserver: AnyObject, Sendable { - - /** - * Deliver a complete replacement tree. - */ - func onUpdate(node: CustomRendererNode) - - /** - * Report that the renderer stream ended without drawing further trees. - * The last tree delivered stands. - */ - func onComplete() - - /** - * Report that the product could not serve this render. The last tree - * delivered, if any, is partial and must not be treated as final. - */ - func onError(reason: String) - -} - - -// Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceNativeCustomRendererObserver { - - // Create the VTable using a series of closures. - // Swift automatically converts these into C callback functions. - // - // Store the vtable directly. - static let vtable: UniffiVTableCallbackInterfaceNativeCustomRendererObserver = UniffiVTableCallbackInterfaceNativeCustomRendererObserver( - uniffiFree: { (uniffiHandle: UInt64) -> () in - do { - try FfiConverterCallbackInterfaceNativeCustomRendererObserver.handleMap.remove(handle: uniffiHandle) - } catch { - print("Uniffi callback interface NativeCustomRendererObserver: handle missing in uniffiFree") - } - }, - uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in - do { - return try FfiConverterCallbackInterfaceNativeCustomRendererObserver.handleMap.clone(handle: uniffiHandle) - } catch { - fatalError("Uniffi callback interface NativeCustomRendererObserver: handle missing in uniffiClone") - } - }, - onUpdate: { ( - uniffiHandle: UInt64, - node: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterCallbackInterfaceNativeCustomRendererObserver.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onUpdate( - node: try FfiConverterTypeCustomRendererNode_lift(node) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onComplete: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterCallbackInterfaceNativeCustomRendererObserver.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onComplete( - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onError: { ( - uniffiHandle: UInt64, - reason: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterCallbackInterfaceNativeCustomRendererObserver.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onError( - reason: try FfiConverterString.lift(reason) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - } - ) - - // Rust stores this pointer for future callback invocations, so it must live - // for the process lifetime (not just for the init function call). - // - // `nonisolated(unsafe)` is needed under Swift 6 strict concurrency. - // This is safe because the pointee is initialized once during static init - // and never mutated by either side of the FFI. Its fields are C function pointers. - nonisolated(unsafe) static let vtablePtr: UnsafePointer = { - let ptr = UnsafeMutablePointer.allocate(capacity: 1) - ptr.initialize(to: vtable) - return UnsafePointer(ptr) - }() -} - -private func uniffiCallbackInitNativeCustomRendererObserver() { - uniffi_truapi_server_fn_init_callback_vtable_nativecustomrendererobserver(UniffiCallbackInterfaceNativeCustomRendererObserver.vtablePtr) -} - -// FfiConverter protocol for callback interfaces -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterCallbackInterfaceNativeCustomRendererObserver { - fileprivate static let handleMap = UniffiHandleMap() -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -extension FfiConverterCallbackInterfaceNativeCustomRendererObserver : FfiConverter { - typealias SwiftType = NativeCustomRendererObserver - typealias FfiType = UInt64 - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ handle: UInt64) throws -> SwiftType { - try handleMap.get(handle: handle) - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ v: SwiftType) -> UInt64 { - return handleMap.insert(obj: v) - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func write(_ v: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(v)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterCallbackInterfaceNativeCustomRendererObserver_lift(_ handle: UInt64) throws -> NativeCustomRendererObserver { - return try FfiConverterCallbackInterfaceNativeCustomRendererObserver.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterCallbackInterfaceNativeCustomRendererObserver_lower(_ v: NativeCustomRendererObserver) -> UInt64 { - return FfiConverterCallbackInterfaceNativeCustomRendererObserver.lower(v) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { - typealias SwiftType = UInt32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt32.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterUInt32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { - typealias SwiftType = String? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterString.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterString.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { - typealias SwiftType = Data? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterData.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterData.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeNativeChatCallbacks: FfiConverterRustBuffer { - typealias SwiftType = NativeChatCallbacks? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeNativeChatCallbacks.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeNativeChatCallbacks.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeStatementRenewalReport: FfiConverterRustBuffer { - typealias SwiftType = StatementRenewalReport? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeStatementRenewalReport.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeStatementRenewalReport.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeBytes32: FfiConverterRustBuffer { - typealias SwiftType = Bytes32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeBytes32.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeBytes32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { - typealias SwiftType = [String] - - public static func write(_ value: [String], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterString.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] { - let len: Int32 = try readInt(&buf) - var seq = [String]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterString.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeChatRoom: FfiConverterRustBuffer { - typealias SwiftType = [ChatRoom] - - public static func write(_ value: [ChatRoom], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeChatRoom.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChatRoom] { - let len: Int32 = try readInt(&buf) - var seq = [ChatRoom]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeChatRoom.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeStatementRenewalOutcome: FfiConverterRustBuffer { - typealias SwiftType = [StatementRenewalOutcome] - - public static func write(_ value: [StatementRenewalOutcome], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeStatementRenewalOutcome.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [StatementRenewalOutcome] { - let len: Int32 = try readInt(&buf) - var seq = [StatementRenewalOutcome]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeStatementRenewalOutcome.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeNativeStatementRenewalTarget: FfiConverterRustBuffer { - typealias SwiftType = [NativeStatementRenewalTarget] - - public static func write(_ value: [NativeStatementRenewalTarget], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeNativeStatementRenewalTarget.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [NativeStatementRenewalTarget] { - let len: Int32 = try readInt(&buf) - var seq = [NativeStatementRenewalTarget]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeNativeStatementRenewalTarget.read(from: &buf)) - } - return seq - } -} -private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0 -private let UNIFFI_RUST_FUTURE_POLL_WAKE: Int8 = 1 - -fileprivate let uniffiContinuationHandleMap = UniffiHandleMap>() - -fileprivate func uniffiRustCallAsync( - rustFutureFunc: () -> UInt64, - pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (), - completeFunc: (UInt64, UnsafeMutablePointer) -> F, - 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() - uniffiEnsureTruapiServerInitialized() - let rustFuture = rustFutureFunc() - defer { - freeFunc(rustFuture) - } - var pollResult: Int8; - repeat { - pollResult = await withUnsafeContinuation { - pollFunc( - rustFuture, - { handle, pollResult in - uniffiFutureContinuationCallback(handle: handle, pollResult: pollResult) - }, - uniffiContinuationHandleMap.insert(obj: $0) - ) - } - } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY - - return try liftFunc(makeRustCall( - { completeFunc(rustFuture, $0) }, - errorHandler: errorHandler - )) -} - -// Callback handlers for an async calls. These are invoked by Rust when the future is ready. They -// lift the return value or error and resume the suspended function. -fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) { - if let continuation = try? uniffiContinuationHandleMap.remove(handle: handle) { - continuation.resume(returning: pollResult) - } else { - print("uniffiFutureContinuationCallback invalid handle") - } -} -private func uniffiTraitInterfaceCallAsync( - makeCall: @escaping () async throws -> T, - handleSuccess: @escaping (T) -> (), - handleError: @escaping (Int8, RustBuffer) -> (), - droppedCallback: UnsafeMutablePointer -) { - let task = Task { - // Note: it's important we call either `handleSuccess` or `handleError` exactly once. Each - // call consumes an Arc reference, which means there should be no possibility of a double - // call. The following code is structured so that will will never call both `handleSuccess` - // and `handleError`, even in the face of weird errors. - // - // On platforms that need extra machinery to make C-ABI calls, like JNA or ctypes, it's - // possible that we fail to make either call. However, it doesn't seem like this is - // possible on Swift since swift can just make the C call directly. - var callResult: T - do { - callResult = try await makeCall() - } catch { - handleError(CALL_UNEXPECTED_ERROR, FfiConverterString.lower(String(describing: error))) - return - } - handleSuccess(callResult) - } - let handle = UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert(obj: task) - droppedCallback.pointee = UniffiForeignFutureDroppedCallbackStruct( - handle: handle, - free: uniffiForeignFutureDroppedCallback - ) -} - -private func uniffiTraitInterfaceCallAsyncWithError( - makeCall: @escaping () async throws -> T, - handleSuccess: @escaping (T) -> (), - handleError: @escaping (Int8, RustBuffer) -> (), - lowerError: @escaping (E) -> RustBuffer, - droppedCallback: UnsafeMutablePointer -) { - let task = Task { - // See the note in uniffiTraitInterfaceCallAsync for details on `handleSuccess` and - // `handleError`. - var callResult: T - do { - callResult = try await makeCall() - } catch let error as E { - handleError(CALL_ERROR, lowerError(error)) - return - } catch { - handleError(CALL_UNEXPECTED_ERROR, FfiConverterString.lower(String(describing: error))) - return - } - handleSuccess(callResult) - } - let handle = UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert(obj: task) - droppedCallback.pointee = UniffiForeignFutureDroppedCallbackStruct( - handle: handle, - free: uniffiForeignFutureDroppedCallback - ) -} - -// Borrow the callback handle map implementation to store foreign future handles -// TODO: consolidate the handle-map code (https://github.com/mozilla/uniffi-rs/pull/1823) -fileprivate let UNIFFI_FOREIGN_FUTURE_HANDLE_MAP = UniffiHandleMap() - -// Protocol for tasks that handle foreign futures. -// -// Defining a protocol allows all tasks to be stored in the same handle map. This can't be done -// with the task object itself, since has generic parameters. -fileprivate protocol UniffiForeignFutureTask { - func cancel() -} - -extension Task: UniffiForeignFutureTask {} - -private func uniffiForeignFutureDroppedCallback(handle: UInt64) { - do { - let task = try UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.remove(handle: handle) - // Set the cancellation flag on the task. If it's still running, the code can check the - // cancellation flag or call `Task.checkCancellation()`. If the task has completed, this is - // a no-op. - task.cancel() - } catch { - print("uniffiForeignFutureDroppedCallback: handle missing from handlemap") - } -} - -// For testing -public func uniffiForeignFutureHandleCountTruapiServer() -> Int { - UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.count -} -/** - * Classify a navigation input exactly like the core's internal navigate host - * call: dotNS first, then `localhost`, then normalized external, with - * everything else rejected. Pure and stateless; hosts call it on every - * webview-internal navigation. - */ -public func parseNavigate(input: String) -> NavigateDecision { - return try! FfiConverterTypeNavigateDecision_lift(try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_func_parse_navigate( - FfiConverterString.lower(input),uniffiCallStatus - ) -}) -} -/** - * Set the live log level (`off`/`error`/`warn`/`info`/`debug`/`trace`) for - * the `tracing` output, which on native routes to stderr (system logs on - * iOS/Android). Most native diagnostics flow through `on_core_log` instead; - * this controls the cross-platform `tracing` events shared with wasm. - */ -public func setLogLevel(level: String) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_server_fn_func_set_log_level( - FfiConverterString.lower(level),uniffiCallStatus - ) -} -} - -private enum InitializationResult { - case ok - case contractVersionMismatch - case apiChecksumMismatch -} -// Use a global variable to perform the versioning checks. Swift ensures that -// the code inside is only computed once. -private let initializationResult: InitializationResult = { - // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 30 - // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_truapi_server_uniffi_contract_version() - if bindings_contract_version != scaffolding_contract_version { - return InitializationResult.contractVersionMismatch - } - if (uniffi_truapi_server_checksum_func_parse_navigate() != 62582) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_func_set_log_level() != 13010) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_on_core_log() != 19934) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_navigate_to() != 5582) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_push_notification() != 62912) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_cancel_notification() != 35695) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_device_permission() != 19880) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_device_permission_status() != 21303) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_remote_permission() != 12868) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_auth_state_changed() != 50346) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_read() != 61703) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_write() != 4428) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_clear() != 43717) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_chain_connect() != 30923) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_chain_send() != 6042) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_chain_close() != 51970) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_confirm_user_action() != 20260) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_lookup_preimage() != 59647) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_current_theme() != 24427) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_current_locale() != 50200) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_feature_supported() != 65446) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_supported_chains() != 46660) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_read() != 43612) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_write() != 39736) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_clear() != 64902) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativechatcallbacks_create_room() != 15676) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativechatcallbacks_register_bot() != 59357) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativechatcallbacks_post_message() != 56893) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativechatcallbacks_list_rooms() != 21374) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_device_encryption_key() != 18707) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chain_closed() != 59343) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chain_response() != 39688) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chat_rooms_changed() != 13112) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_locale_changed() != 43759) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_preimage_changed() != 21769) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_notify_theme_changed() != 3284) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_permission_authorization_status() != 27339) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_product_subtree_public_key() != 63238) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_publish_chat_action() != 31503) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_render_custom_message() != 17716) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_session_chat_identity_key() != 3903) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_set_permission_authorization_status() != 14164) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_shutdown() != 56769) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_start_ws_bridge() != 16029) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativeproductexecution_stop_ws_bridge() != 6101) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_activate_local_session() != 40075) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_disconnect() != 38487) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_handle_sso_request() != 21060) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_last_statement_renewal_report() != 40119) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_next_statement_renewal_delay() != 33452) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_notify_chain_closed() != 55360) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_notify_chain_response() != 26715) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_open_product_execution() != 49537) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_prepare_disconnect_request() != 17252) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_renew_statement_allowances() != 11225) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_start_statement_allowance_renewal() != 18621) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativetruapihostruntime_track_statement_renewal_targets() != 53330) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativecustomrenderersubscription_cancel() != 26593) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_constructor_nativetruapihostruntime_with_runtime_config() != 39293) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_update() != 1079) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_complete() != 32694) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_error() != 21230) { - return InitializationResult.apiChecksumMismatch - } - - uniffiCallbackInitHostCallbacks() - uniffiCallbackInitNativeChatCallbacks() - uniffiCallbackInitNativeCustomRendererObserver() - uniffiEnsureTruapiInitialized() - uniffiEnsureTruapiPlatformInitialized() - return InitializationResult.ok -}() - -// Make the ensure init function public so that other modules which have external type references to -// our types can call it. -public func uniffiEnsureTruapiServerInitialized() { - switch initializationResult { - case .ok: - break - case .contractVersionMismatch: - fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") - case .apiChecksumMismatch: - fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } -} - -// swiftlint:enable all \ No newline at end of file diff --git a/ios/truapi-host/Sources/truapiFFI/include/module.modulemap b/ios/truapi-host/Sources/truapiFFI/include/module.modulemap deleted file mode 100644 index e7c3885b5..000000000 --- a/ios/truapi-host/Sources/truapiFFI/include/module.modulemap +++ /dev/null @@ -1,7 +0,0 @@ -module truapiFFI { - header "truapiFFI.h" - export * - use "Darwin" - use "_Builtin_stdbool" - use "_Builtin_stdint" -} \ No newline at end of file diff --git a/ios/truapi-host/Sources/truapiFFI/include/truapiFFI.h b/ios/truapi-host/Sources/truapiFFI/include/truapiFFI.h deleted file mode 100644 index 6530e07d2..000000000 --- a/ios/truapi-host/Sources/truapiFFI/include/truapiFFI.h +++ /dev/null @@ -1,512 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -#pragma once - -#include -#include -#include - -// The following structs are used to implement the lowest level -// of the FFI, and thus useful to multiple uniffied crates. -// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. -#ifdef UNIFFI_SHARED_H - // We also try to prevent mixing versions of shared uniffi header structs. - // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 - #ifndef UNIFFI_SHARED_HEADER_V4 - #error Combining helper code from multiple versions of uniffi is not supported - #endif // ndef UNIFFI_SHARED_HEADER_V4 -#else -#define UNIFFI_SHARED_H -#define UNIFFI_SHARED_HEADER_V4 -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ - -typedef struct RustBuffer -{ - uint64_t capacity; - uint64_t len; - uint8_t *_Nullable data; -} RustBuffer; - -typedef struct ForeignBytes -{ - int32_t len; - const uint8_t *_Nullable data; -} ForeignBytes; - -// Error definitions -typedef struct RustCallStatus { - int8_t code; - RustBuffer errorBuf; -} RustCallStatus; - -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ -#endif // def UNIFFI_SHARED_H -#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -typedef void (*UniffiCallbackInterfaceFree)(uint64_t - ); - -#endif -#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; - UniffiForeignFutureDroppedCallback _Nonnull free; -} UniffiForeignFutureDroppedCallbackStruct; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -typedef struct UniffiForeignFutureResultU8 { - uint8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -typedef struct UniffiForeignFutureResultI8 { - int8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -typedef struct UniffiForeignFutureResultU16 { - uint16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -typedef struct UniffiForeignFutureResultI16 { - int16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -typedef struct UniffiForeignFutureResultU32 { - uint32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -typedef struct UniffiForeignFutureResultI32 { - int32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -typedef struct UniffiForeignFutureResultU64 { - uint64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -typedef struct UniffiForeignFutureResultI64 { - int64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -typedef struct UniffiForeignFutureResultF32 { - float returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -typedef struct UniffiForeignFutureResultF64 { - double returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -typedef struct UniffiForeignFutureResultRustBuffer { - RustBuffer returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultRustBuffer; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -typedef struct UniffiForeignFutureResultVoid { - RustCallStatus callStatus; -} UniffiForeignFutureResultVoid; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid - ); - -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_ALLOC -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_ALLOC -RustBuffer ffi_truapi_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_FROM_BYTES -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_FROM_BYTES -RustBuffer ffi_truapi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_FREE -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_FREE -void ffi_truapi_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_RESERVE -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUSTBUFFER_RESERVE -RustBuffer ffi_truapi_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U8 -void ffi_truapi_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U8 -void ffi_truapi_rust_future_cancel_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U8 -void ffi_truapi_rust_future_free_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U8 -uint8_t ffi_truapi_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I8 -void ffi_truapi_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I8 -void ffi_truapi_rust_future_cancel_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I8 -void ffi_truapi_rust_future_free_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I8 -int8_t ffi_truapi_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U16 -void ffi_truapi_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U16 -void ffi_truapi_rust_future_cancel_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U16 -void ffi_truapi_rust_future_free_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U16 -uint16_t ffi_truapi_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I16 -void ffi_truapi_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I16 -void ffi_truapi_rust_future_cancel_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I16 -void ffi_truapi_rust_future_free_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I16 -int16_t ffi_truapi_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U32 -void ffi_truapi_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U32 -void ffi_truapi_rust_future_cancel_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U32 -void ffi_truapi_rust_future_free_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U32 -uint32_t ffi_truapi_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I32 -void ffi_truapi_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I32 -void ffi_truapi_rust_future_cancel_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I32 -void ffi_truapi_rust_future_free_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I32 -int32_t ffi_truapi_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_U64 -void ffi_truapi_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_U64 -void ffi_truapi_rust_future_cancel_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_U64 -void ffi_truapi_rust_future_free_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_U64 -uint64_t ffi_truapi_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_I64 -void ffi_truapi_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_I64 -void ffi_truapi_rust_future_cancel_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_I64 -void ffi_truapi_rust_future_free_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_I64 -int64_t ffi_truapi_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_F32 -void ffi_truapi_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_F32 -void ffi_truapi_rust_future_cancel_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_F32 -void ffi_truapi_rust_future_free_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_F32 -float ffi_truapi_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_F64 -void ffi_truapi_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_F64 -void ffi_truapi_rust_future_cancel_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_F64 -void ffi_truapi_rust_future_free_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_F64 -double ffi_truapi_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_RUST_BUFFER -void ffi_truapi_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_RUST_BUFFER -void ffi_truapi_rust_future_cancel_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_RUST_BUFFER -void ffi_truapi_rust_future_free_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_RUST_BUFFER -RustBuffer ffi_truapi_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_POLL_VOID -void ffi_truapi_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_CANCEL_VOID -void ffi_truapi_rust_future_cancel_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_FREE_VOID -void ffi_truapi_rust_future_free_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_RUST_FUTURE_COMPLETE_VOID -void ffi_truapi_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_UNIFFI_CONTRACT_VERSION -#define UNIFFI_FFIDEF_FFI_TRUAPI_UNIFFI_CONTRACT_VERSION -uint32_t ffi_truapi_uniffi_contract_version(void - -); -#endif - diff --git a/ios/truapi-host/Sources/truapi_platformFFI/include/module.modulemap b/ios/truapi-host/Sources/truapi_platformFFI/include/module.modulemap deleted file mode 100644 index 8f0914104..000000000 --- a/ios/truapi-host/Sources/truapi_platformFFI/include/module.modulemap +++ /dev/null @@ -1,7 +0,0 @@ -module truapi_platformFFI { - header "truapi_platformFFI.h" - export * - use "Darwin" - use "_Builtin_stdbool" - use "_Builtin_stdint" -} \ No newline at end of file diff --git a/ios/truapi-host/Sources/truapi_platformFFI/include/truapi_platformFFI.h b/ios/truapi-host/Sources/truapi_platformFFI/include/truapi_platformFFI.h deleted file mode 100644 index 969521c6d..000000000 --- a/ios/truapi-host/Sources/truapi_platformFFI/include/truapi_platformFFI.h +++ /dev/null @@ -1,512 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -#pragma once - -#include -#include -#include - -// The following structs are used to implement the lowest level -// of the FFI, and thus useful to multiple uniffied crates. -// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. -#ifdef UNIFFI_SHARED_H - // We also try to prevent mixing versions of shared uniffi header structs. - // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 - #ifndef UNIFFI_SHARED_HEADER_V4 - #error Combining helper code from multiple versions of uniffi is not supported - #endif // ndef UNIFFI_SHARED_HEADER_V4 -#else -#define UNIFFI_SHARED_H -#define UNIFFI_SHARED_HEADER_V4 -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ - -typedef struct RustBuffer -{ - uint64_t capacity; - uint64_t len; - uint8_t *_Nullable data; -} RustBuffer; - -typedef struct ForeignBytes -{ - int32_t len; - const uint8_t *_Nullable data; -} ForeignBytes; - -// Error definitions -typedef struct RustCallStatus { - int8_t code; - RustBuffer errorBuf; -} RustCallStatus; - -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ -#endif // def UNIFFI_SHARED_H -#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -typedef void (*UniffiCallbackInterfaceFree)(uint64_t - ); - -#endif -#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; - UniffiForeignFutureDroppedCallback _Nonnull free; -} UniffiForeignFutureDroppedCallbackStruct; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -typedef struct UniffiForeignFutureResultU8 { - uint8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -typedef struct UniffiForeignFutureResultI8 { - int8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -typedef struct UniffiForeignFutureResultU16 { - uint16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -typedef struct UniffiForeignFutureResultI16 { - int16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -typedef struct UniffiForeignFutureResultU32 { - uint32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -typedef struct UniffiForeignFutureResultI32 { - int32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -typedef struct UniffiForeignFutureResultU64 { - uint64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -typedef struct UniffiForeignFutureResultI64 { - int64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -typedef struct UniffiForeignFutureResultF32 { - float returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -typedef struct UniffiForeignFutureResultF64 { - double returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -typedef struct UniffiForeignFutureResultRustBuffer { - RustBuffer returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultRustBuffer; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -typedef struct UniffiForeignFutureResultVoid { - RustCallStatus callStatus; -} UniffiForeignFutureResultVoid; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid - ); - -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_ALLOC -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_ALLOC -RustBuffer ffi_truapi_platform_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_FROM_BYTES -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_FROM_BYTES -RustBuffer ffi_truapi_platform_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_FREE -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_FREE -void ffi_truapi_platform_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_RESERVE -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUSTBUFFER_RESERVE -RustBuffer ffi_truapi_platform_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U8 -void ffi_truapi_platform_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U8 -void ffi_truapi_platform_rust_future_cancel_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U8 -void ffi_truapi_platform_rust_future_free_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U8 -uint8_t ffi_truapi_platform_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I8 -void ffi_truapi_platform_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I8 -void ffi_truapi_platform_rust_future_cancel_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I8 -void ffi_truapi_platform_rust_future_free_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I8 -int8_t ffi_truapi_platform_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U16 -void ffi_truapi_platform_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U16 -void ffi_truapi_platform_rust_future_cancel_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U16 -void ffi_truapi_platform_rust_future_free_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U16 -uint16_t ffi_truapi_platform_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I16 -void ffi_truapi_platform_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I16 -void ffi_truapi_platform_rust_future_cancel_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I16 -void ffi_truapi_platform_rust_future_free_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I16 -int16_t ffi_truapi_platform_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U32 -void ffi_truapi_platform_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U32 -void ffi_truapi_platform_rust_future_cancel_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U32 -void ffi_truapi_platform_rust_future_free_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U32 -uint32_t ffi_truapi_platform_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I32 -void ffi_truapi_platform_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I32 -void ffi_truapi_platform_rust_future_cancel_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I32 -void ffi_truapi_platform_rust_future_free_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I32 -int32_t ffi_truapi_platform_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_U64 -void ffi_truapi_platform_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_U64 -void ffi_truapi_platform_rust_future_cancel_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_U64 -void ffi_truapi_platform_rust_future_free_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_U64 -uint64_t ffi_truapi_platform_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_I64 -void ffi_truapi_platform_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_I64 -void ffi_truapi_platform_rust_future_cancel_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_I64 -void ffi_truapi_platform_rust_future_free_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_I64 -int64_t ffi_truapi_platform_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_F32 -void ffi_truapi_platform_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_F32 -void ffi_truapi_platform_rust_future_cancel_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_F32 -void ffi_truapi_platform_rust_future_free_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_F32 -float ffi_truapi_platform_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_F64 -void ffi_truapi_platform_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_F64 -void ffi_truapi_platform_rust_future_cancel_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_F64 -void ffi_truapi_platform_rust_future_free_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_F64 -double ffi_truapi_platform_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_RUST_BUFFER -void ffi_truapi_platform_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_RUST_BUFFER -void ffi_truapi_platform_rust_future_cancel_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_RUST_BUFFER -void ffi_truapi_platform_rust_future_free_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_RUST_BUFFER -RustBuffer ffi_truapi_platform_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_POLL_VOID -void ffi_truapi_platform_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_CANCEL_VOID -void ffi_truapi_platform_rust_future_cancel_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_FREE_VOID -void ffi_truapi_platform_rust_future_free_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_RUST_FUTURE_COMPLETE_VOID -void ffi_truapi_platform_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_UNIFFI_CONTRACT_VERSION -#define UNIFFI_FFIDEF_FFI_TRUAPI_PLATFORM_UNIFFI_CONTRACT_VERSION -uint32_t ffi_truapi_platform_uniffi_contract_version(void - -); -#endif - diff --git a/ios/truapi-host/Sources/truapi_serverFFI/include/module.modulemap b/ios/truapi-host/Sources/truapi_serverFFI/include/module.modulemap deleted file mode 100644 index 49d064ea3..000000000 --- a/ios/truapi-host/Sources/truapi_serverFFI/include/module.modulemap +++ /dev/null @@ -1,7 +0,0 @@ -module truapi_serverFFI { - header "truapi_serverFFI.h" - export * - use "Darwin" - use "_Builtin_stdbool" - use "_Builtin_stdint" -} \ No newline at end of file diff --git a/ios/truapi-host/Sources/truapi_serverFFI/include/truapi_serverFFI.h b/ios/truapi-host/Sources/truapi_serverFFI/include/truapi_serverFFI.h deleted file mode 100644 index 6595a1494..000000000 --- a/ios/truapi-host/Sources/truapi_serverFFI/include/truapi_serverFFI.h +++ /dev/null @@ -1,1500 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -#pragma once - -#include -#include -#include - -// The following structs are used to implement the lowest level -// of the FFI, and thus useful to multiple uniffied crates. -// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. -#ifdef UNIFFI_SHARED_H - // We also try to prevent mixing versions of shared uniffi header structs. - // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 - #ifndef UNIFFI_SHARED_HEADER_V4 - #error Combining helper code from multiple versions of uniffi is not supported - #endif // ndef UNIFFI_SHARED_HEADER_V4 -#else -#define UNIFFI_SHARED_H -#define UNIFFI_SHARED_HEADER_V4 -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ - -typedef struct RustBuffer -{ - uint64_t capacity; - uint64_t len; - uint8_t *_Nullable data; -} RustBuffer; - -typedef struct ForeignBytes -{ - int32_t len; - const uint8_t *_Nullable data; -} ForeignBytes; - -// Error definitions -typedef struct RustCallStatus { - int8_t code; - RustBuffer errorBuf; -} RustCallStatus; - -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ -#endif // def UNIFFI_SHARED_H -#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -typedef void (*UniffiCallbackInterfaceFree)(uint64_t - ); - -#endif -#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; - UniffiForeignFutureDroppedCallback _Nonnull free; -} UniffiForeignFutureDroppedCallbackStruct; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -typedef struct UniffiForeignFutureResultU8 { - uint8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -typedef struct UniffiForeignFutureResultI8 { - int8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -typedef struct UniffiForeignFutureResultU16 { - uint16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -typedef struct UniffiForeignFutureResultI16 { - int16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -typedef struct UniffiForeignFutureResultU32 { - uint32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -typedef struct UniffiForeignFutureResultI32 { - int32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -typedef struct UniffiForeignFutureResultU64 { - uint64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -typedef struct UniffiForeignFutureResultI64 { - int64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -typedef struct UniffiForeignFutureResultF32 { - float returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -typedef struct UniffiForeignFutureResultF64 { - double returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -typedef struct UniffiForeignFutureResultRustBuffer { - RustBuffer returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultRustBuffer; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -typedef struct UniffiForeignFutureResultVoid { - RustCallStatus callStatus; -} UniffiForeignFutureResultVoid; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD0 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD0 -typedef void (*UniffiCallbackInterfaceNativeCustomRendererObserverMethod0)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD1 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD1 -typedef void (*UniffiCallbackInterfaceNativeCustomRendererObserverMethod1)(uint64_t, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD2 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER_METHOD2 -typedef void (*UniffiCallbackInterfaceNativeCustomRendererObserverMethod2)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD0 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD0 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod0)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD1 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD1 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod1)(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD2 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD2 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod2)(uint64_t, RustBuffer, UniffiForeignFutureCompleteU32 _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD3 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD3 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod3)(uint64_t, uint32_t, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD4 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD4 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod4)(uint64_t, RustBuffer, UniffiForeignFutureCompleteI8 _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD5 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD5 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod5)(uint64_t, RustBuffer, UniffiForeignFutureCompleteRustBuffer _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD6 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD6 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod6)(uint64_t, RustBuffer, UniffiForeignFutureCompleteI8 _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD7 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD7 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod7)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD8 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD8 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod8)(uint64_t, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD9 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD9 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod9)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD10 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD10 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod10)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD11 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD11 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod11)(uint64_t, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD12 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD12 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod12)(uint64_t, uint32_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD13 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD13 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod13)(uint64_t, uint32_t, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD14 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD14 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod14)(uint64_t, RustBuffer, UniffiForeignFutureCompleteI8 _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD15 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD15 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod15)(uint64_t, RustBuffer, UniffiForeignFutureCompleteRustBuffer _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD16 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD16 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod16)(uint64_t, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD17 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD17 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod17)(uint64_t, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD18 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD18 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod18)(uint64_t, RustBuffer, UniffiForeignFutureCompleteI8 _Nonnull, uint64_t, UniffiForeignFutureDroppedCallbackStruct* _Nonnull - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD19 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD19 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod19)(uint64_t, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD20 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD20 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod20)(uint64_t, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD21 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD21 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod21)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD22 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_HOST_CALLBACKS_METHOD22 -typedef void (*UniffiCallbackInterfaceHostCallbacksMethod22)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD0 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD0 -typedef void (*UniffiCallbackInterfaceNativeChatCallbacksMethod0)(uint64_t, RustBuffer, RustBuffer, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD1 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD1 -typedef void (*UniffiCallbackInterfaceNativeChatCallbacksMethod1)(uint64_t, RustBuffer, RustBuffer, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD2 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD2 -typedef void (*UniffiCallbackInterfaceNativeChatCallbacksMethod2)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD3 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS_METHOD3 -typedef void (*UniffiCallbackInterfaceNativeChatCallbacksMethod3)(uint64_t, RustBuffer* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER -#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_NATIVE_CUSTOM_RENDERER_OBSERVER -typedef struct UniffiVTableCallbackInterfaceNativeCustomRendererObserver { - UniffiCallbackInterfaceFree _Nonnull uniffiFree; - UniffiCallbackInterfaceClone _Nonnull uniffiClone; - UniffiCallbackInterfaceNativeCustomRendererObserverMethod0 _Nonnull onUpdate; - UniffiCallbackInterfaceNativeCustomRendererObserverMethod1 _Nonnull onComplete; - UniffiCallbackInterfaceNativeCustomRendererObserverMethod2 _Nonnull onError; -} UniffiVTableCallbackInterfaceNativeCustomRendererObserver; - -#endif -#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_HOST_CALLBACKS -#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_HOST_CALLBACKS -typedef struct UniffiVTableCallbackInterfaceHostCallbacks { - UniffiCallbackInterfaceFree _Nonnull uniffiFree; - UniffiCallbackInterfaceClone _Nonnull uniffiClone; - UniffiCallbackInterfaceHostCallbacksMethod0 _Nonnull onCoreLog; - UniffiCallbackInterfaceHostCallbacksMethod1 _Nonnull navigateTo; - UniffiCallbackInterfaceHostCallbacksMethod2 _Nonnull pushNotification; - UniffiCallbackInterfaceHostCallbacksMethod3 _Nonnull cancelNotification; - UniffiCallbackInterfaceHostCallbacksMethod4 _Nonnull devicePermission; - UniffiCallbackInterfaceHostCallbacksMethod5 _Nonnull devicePermissionStatus; - UniffiCallbackInterfaceHostCallbacksMethod6 _Nonnull remotePermission; - UniffiCallbackInterfaceHostCallbacksMethod7 _Nonnull authStateChanged; - UniffiCallbackInterfaceHostCallbacksMethod8 _Nonnull coreStorageRead; - UniffiCallbackInterfaceHostCallbacksMethod9 _Nonnull coreStorageWrite; - UniffiCallbackInterfaceHostCallbacksMethod10 _Nonnull coreStorageClear; - UniffiCallbackInterfaceHostCallbacksMethod11 _Nonnull chainConnect; - UniffiCallbackInterfaceHostCallbacksMethod12 _Nonnull chainSend; - UniffiCallbackInterfaceHostCallbacksMethod13 _Nonnull chainClose; - UniffiCallbackInterfaceHostCallbacksMethod14 _Nonnull confirmUserAction; - UniffiCallbackInterfaceHostCallbacksMethod15 _Nonnull lookupPreimage; - UniffiCallbackInterfaceHostCallbacksMethod16 _Nonnull currentTheme; - UniffiCallbackInterfaceHostCallbacksMethod17 _Nonnull currentLocale; - UniffiCallbackInterfaceHostCallbacksMethod18 _Nonnull featureSupported; - UniffiCallbackInterfaceHostCallbacksMethod19 _Nonnull supportedChains; - UniffiCallbackInterfaceHostCallbacksMethod20 _Nonnull localStorageRead; - UniffiCallbackInterfaceHostCallbacksMethod21 _Nonnull localStorageWrite; - UniffiCallbackInterfaceHostCallbacksMethod22 _Nonnull localStorageClear; -} UniffiVTableCallbackInterfaceHostCallbacks; - -#endif -#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS -#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_NATIVE_CHAT_CALLBACKS -typedef struct UniffiVTableCallbackInterfaceNativeChatCallbacks { - UniffiCallbackInterfaceFree _Nonnull uniffiFree; - UniffiCallbackInterfaceClone _Nonnull uniffiClone; - UniffiCallbackInterfaceNativeChatCallbacksMethod0 _Nonnull createRoom; - UniffiCallbackInterfaceNativeChatCallbacksMethod1 _Nonnull registerBot; - UniffiCallbackInterfaceNativeChatCallbacksMethod2 _Nonnull postMessage; - UniffiCallbackInterfaceNativeChatCallbacksMethod3 _Nonnull listRooms; -} UniffiVTableCallbackInterfaceNativeChatCallbacks; - -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_HOSTCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_HOSTCALLBACKS -uint64_t uniffi_truapi_server_fn_clone_hostcallbacks(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_HOSTCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_HOSTCALLBACKS -void uniffi_truapi_server_fn_free_hostcallbacks(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_HOSTCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_HOSTCALLBACKS -void uniffi_truapi_server_fn_init_callback_vtable_hostcallbacks(const UniffiVTableCallbackInterfaceHostCallbacks* _Nonnull vtable -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_ON_CORE_LOG -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_ON_CORE_LOG -void uniffi_truapi_server_fn_method_hostcallbacks_on_core_log(uint64_t ptr, RustBuffer marker, RustBuffer detail, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_NAVIGATE_TO -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_NAVIGATE_TO -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_navigate_to(uint64_t ptr, RustBuffer url -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_PUSH_NOTIFICATION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_PUSH_NOTIFICATION -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_push_notification(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CANCEL_NOTIFICATION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CANCEL_NOTIFICATION -void uniffi_truapi_server_fn_method_hostcallbacks_cancel_notification(uint64_t ptr, uint32_t id, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_device_permission(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION_STATUS -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_device_permission_status(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_REMOTE_PERMISSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_REMOTE_PERMISSION -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_remote_permission(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_AUTH_STATE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_AUTH_STATE_CHANGED -void uniffi_truapi_server_fn_method_hostcallbacks_auth_state_changed(uint64_t ptr, RustBuffer state, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_READ -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_READ -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_core_storage_read(uint64_t ptr, RustBuffer key, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_WRITE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_WRITE -void uniffi_truapi_server_fn_method_hostcallbacks_core_storage_write(uint64_t ptr, RustBuffer key, RustBuffer value, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_CLEAR -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CORE_STORAGE_CLEAR -void uniffi_truapi_server_fn_method_hostcallbacks_core_storage_clear(uint64_t ptr, RustBuffer key, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_CONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_CONNECT -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_chain_connect(uint64_t ptr, RustBuffer genesis_hash, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_SEND -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_SEND -void uniffi_truapi_server_fn_method_hostcallbacks_chain_send(uint64_t ptr, uint32_t connection_id, RustBuffer request, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_CLOSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CHAIN_CLOSE -void uniffi_truapi_server_fn_method_hostcallbacks_chain_close(uint64_t ptr, uint32_t connection_id, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CONFIRM_USER_ACTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CONFIRM_USER_ACTION -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_confirm_user_action(uint64_t ptr, RustBuffer review -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOOKUP_PREIMAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOOKUP_PREIMAGE -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_lookup_preimage(uint64_t ptr, RustBuffer key -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CURRENT_THEME -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CURRENT_THEME -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_current_theme(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CURRENT_LOCALE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_CURRENT_LOCALE -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_current_locale(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_FEATURE_SUPPORTED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_FEATURE_SUPPORTED -uint64_t uniffi_truapi_server_fn_method_hostcallbacks_feature_supported(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_SUPPORTED_CHAINS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_SUPPORTED_CHAINS -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_supported_chains(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_READ -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_READ -RustBuffer uniffi_truapi_server_fn_method_hostcallbacks_local_storage_read(uint64_t ptr, RustBuffer key, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_WRITE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_WRITE -void uniffi_truapi_server_fn_method_hostcallbacks_local_storage_write(uint64_t ptr, RustBuffer key, RustBuffer value, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_CLEAR -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_CLEAR -void uniffi_truapi_server_fn_method_hostcallbacks_local_storage_clear(uint64_t ptr, RustBuffer key, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVECHATCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVECHATCALLBACKS -uint64_t uniffi_truapi_server_fn_clone_nativechatcallbacks(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVECHATCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVECHATCALLBACKS -void uniffi_truapi_server_fn_free_nativechatcallbacks(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_NATIVECHATCALLBACKS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_NATIVECHATCALLBACKS -void uniffi_truapi_server_fn_init_callback_vtable_nativechatcallbacks(const UniffiVTableCallbackInterfaceNativeChatCallbacks* _Nonnull vtable -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_CREATE_ROOM -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_CREATE_ROOM -RustBuffer uniffi_truapi_server_fn_method_nativechatcallbacks_create_room(uint64_t ptr, RustBuffer room_id, RustBuffer name, RustBuffer icon, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_REGISTER_BOT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_REGISTER_BOT -RustBuffer uniffi_truapi_server_fn_method_nativechatcallbacks_register_bot(uint64_t ptr, RustBuffer bot_id, RustBuffer name, RustBuffer icon, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_POST_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_POST_MESSAGE -RustBuffer uniffi_truapi_server_fn_method_nativechatcallbacks_post_message(uint64_t ptr, RustBuffer room_id, RustBuffer content, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_LIST_ROOMS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECHATCALLBACKS_LIST_ROOMS -RustBuffer uniffi_truapi_server_fn_method_nativechatcallbacks_list_rooms(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVEPRODUCTEXECUTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVEPRODUCTEXECUTION -uint64_t uniffi_truapi_server_fn_clone_nativeproductexecution(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVEPRODUCTEXECUTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVEPRODUCTEXECUTION -void uniffi_truapi_server_fn_free_nativeproductexecution(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_DEVICE_ENCRYPTION_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_DEVICE_ENCRYPTION_KEY -RustBuffer uniffi_truapi_server_fn_method_nativeproductexecution_device_encryption_key(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_CLOSED -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_chain_closed(uint64_t ptr, uint32_t connection_id, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_RESPONSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_RESPONSE -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_chain_response(uint64_t ptr, uint32_t connection_id, RustBuffer json, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAT_ROOMS_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAT_ROOMS_CHANGED -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_chat_rooms_changed(uint64_t ptr, RustBuffer rooms, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_LOCALE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_LOCALE_CHANGED -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_locale_changed(uint64_t ptr, RustBuffer locale, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_PREIMAGE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_PREIMAGE_CHANGED -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_preimage_changed(uint64_t ptr, RustBuffer key, RustBuffer value, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_THEME_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_THEME_CHANGED -void uniffi_truapi_server_fn_method_nativeproductexecution_notify_theme_changed(uint64_t ptr, RustBuffer theme, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PERMISSION_AUTHORIZATION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PERMISSION_AUTHORIZATION_STATUS -uint64_t uniffi_truapi_server_fn_method_nativeproductexecution_permission_authorization_status(uint64_t ptr, RustBuffer request -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PRODUCT_SUBTREE_PUBLIC_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PRODUCT_SUBTREE_PUBLIC_KEY -RustBuffer uniffi_truapi_server_fn_method_nativeproductexecution_product_subtree_public_key(uint64_t ptr, RustBuffer product_id, RustBuffer timeout_ms, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PUBLISH_CHAT_ACTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_PUBLISH_CHAT_ACTION -void uniffi_truapi_server_fn_method_nativeproductexecution_publish_chat_action(uint64_t ptr, RustBuffer action, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_RENDER_CUSTOM_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_RENDER_CUSTOM_MESSAGE -uint64_t uniffi_truapi_server_fn_method_nativeproductexecution_render_custom_message(uint64_t ptr, RustBuffer message_id, RustBuffer message_type, RustBuffer payload, uint64_t observer, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SESSION_CHAT_IDENTITY_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SESSION_CHAT_IDENTITY_KEY -RustBuffer uniffi_truapi_server_fn_method_nativeproductexecution_session_chat_identity_key(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SET_PERMISSION_AUTHORIZATION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SET_PERMISSION_AUTHORIZATION_STATUS -void uniffi_truapi_server_fn_method_nativeproductexecution_set_permission_authorization_status(uint64_t ptr, RustBuffer request, RustBuffer status, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SHUTDOWN -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_SHUTDOWN -void uniffi_truapi_server_fn_method_nativeproductexecution_shutdown(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_START_WS_BRIDGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_START_WS_BRIDGE -RustBuffer uniffi_truapi_server_fn_method_nativeproductexecution_start_ws_bridge(uint64_t ptr, uint16_t bind_port, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_STOP_WS_BRIDGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVEPRODUCTEXECUTION_STOP_WS_BRIDGE -void uniffi_truapi_server_fn_method_nativeproductexecution_stop_ws_bridge(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVETRUAPIHOSTRUNTIME -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVETRUAPIHOSTRUNTIME -uint64_t uniffi_truapi_server_fn_clone_nativetruapihostruntime(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVETRUAPIHOSTRUNTIME -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVETRUAPIHOSTRUNTIME -void uniffi_truapi_server_fn_free_nativetruapihostruntime(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CONSTRUCTOR_NATIVETRUAPIHOSTRUNTIME_WITH_RUNTIME_CONFIG -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CONSTRUCTOR_NATIVETRUAPIHOSTRUNTIME_WITH_RUNTIME_CONFIG -uint64_t uniffi_truapi_server_fn_constructor_nativetruapihostruntime_with_runtime_config(uint64_t callbacks, RustBuffer runtime_config, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_ACTIVATE_LOCAL_SESSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_ACTIVATE_LOCAL_SESSION -void uniffi_truapi_server_fn_method_nativetruapihostruntime_activate_local_session(uint64_t ptr, RustBuffer secret, RustBuffer lite_username, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_DISCONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_DISCONNECT -void uniffi_truapi_server_fn_method_nativetruapihostruntime_disconnect(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_HANDLE_SSO_REQUEST -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_HANDLE_SSO_REQUEST -uint64_t uniffi_truapi_server_fn_method_nativetruapihostruntime_handle_sso_request(uint64_t ptr, RustBuffer message -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_LAST_STATEMENT_RENEWAL_REPORT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_LAST_STATEMENT_RENEWAL_REPORT -RustBuffer uniffi_truapi_server_fn_method_nativetruapihostruntime_last_statement_renewal_report(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NEXT_STATEMENT_RENEWAL_DELAY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NEXT_STATEMENT_RENEWAL_DELAY -RustBuffer uniffi_truapi_server_fn_method_nativetruapihostruntime_next_statement_renewal_delay(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_CLOSED -void uniffi_truapi_server_fn_method_nativetruapihostruntime_notify_chain_closed(uint64_t ptr, uint32_t connection_id, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_RESPONSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_RESPONSE -void uniffi_truapi_server_fn_method_nativetruapihostruntime_notify_chain_response(uint64_t ptr, uint32_t connection_id, RustBuffer json, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_OPEN_PRODUCT_EXECUTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_OPEN_PRODUCT_EXECUTION -uint64_t uniffi_truapi_server_fn_method_nativetruapihostruntime_open_product_execution(uint64_t ptr, uint64_t callbacks, RustBuffer chat_callbacks, RustBuffer execution_config, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_PREPARE_DISCONNECT_REQUEST -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_PREPARE_DISCONNECT_REQUEST -RustBuffer uniffi_truapi_server_fn_method_nativetruapihostruntime_prepare_disconnect_request(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_RENEW_STATEMENT_ALLOWANCES -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_RENEW_STATEMENT_ALLOWANCES -RustBuffer uniffi_truapi_server_fn_method_nativetruapihostruntime_renew_statement_allowances(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_START_STATEMENT_ALLOWANCE_RENEWAL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_START_STATEMENT_ALLOWANCE_RENEWAL -void uniffi_truapi_server_fn_method_nativetruapihostruntime_start_statement_allowance_renewal(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_TRACK_STATEMENT_RENEWAL_TARGETS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVETRUAPIHOSTRUNTIME_TRACK_STATEMENT_RENEWAL_TARGETS -void uniffi_truapi_server_fn_method_nativetruapihostruntime_track_statement_renewal_targets(uint64_t ptr, RustBuffer targets, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVECUSTOMRENDERERSUBSCRIPTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_CLONE_NATIVECUSTOMRENDERERSUBSCRIPTION -uint64_t uniffi_truapi_server_fn_clone_nativecustomrenderersubscription(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVECUSTOMRENDERERSUBSCRIPTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FREE_NATIVECUSTOMRENDERERSUBSCRIPTION -void uniffi_truapi_server_fn_free_nativecustomrenderersubscription(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECUSTOMRENDERERSUBSCRIPTION_CANCEL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_METHOD_NATIVECUSTOMRENDERERSUBSCRIPTION_CANCEL -void uniffi_truapi_server_fn_method_nativecustomrenderersubscription_cancel(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_NATIVECUSTOMRENDEREROBSERVER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_INIT_CALLBACK_VTABLE_NATIVECUSTOMRENDEREROBSERVER -void uniffi_truapi_server_fn_init_callback_vtable_nativecustomrendererobserver(const UniffiVTableCallbackInterfaceNativeCustomRendererObserver* _Nonnull vtable -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FUNC_PARSE_NAVIGATE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FUNC_PARSE_NAVIGATE -RustBuffer uniffi_truapi_server_fn_func_parse_navigate(RustBuffer input, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FUNC_SET_LOG_LEVEL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_FN_FUNC_SET_LOG_LEVEL -void uniffi_truapi_server_fn_func_set_log_level(RustBuffer level, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_ALLOC -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_ALLOC -RustBuffer ffi_truapi_server_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_FROM_BYTES -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_FROM_BYTES -RustBuffer ffi_truapi_server_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_FREE -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_FREE -void ffi_truapi_server_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_RESERVE -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUSTBUFFER_RESERVE -RustBuffer ffi_truapi_server_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U8 -void ffi_truapi_server_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U8 -void ffi_truapi_server_rust_future_cancel_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U8 -void ffi_truapi_server_rust_future_free_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U8 -uint8_t ffi_truapi_server_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I8 -void ffi_truapi_server_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I8 -void ffi_truapi_server_rust_future_cancel_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I8 -void ffi_truapi_server_rust_future_free_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I8 -int8_t ffi_truapi_server_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U16 -void ffi_truapi_server_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U16 -void ffi_truapi_server_rust_future_cancel_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U16 -void ffi_truapi_server_rust_future_free_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U16 -uint16_t ffi_truapi_server_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I16 -void ffi_truapi_server_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I16 -void ffi_truapi_server_rust_future_cancel_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I16 -void ffi_truapi_server_rust_future_free_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I16 -int16_t ffi_truapi_server_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U32 -void ffi_truapi_server_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U32 -void ffi_truapi_server_rust_future_cancel_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U32 -void ffi_truapi_server_rust_future_free_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U32 -uint32_t ffi_truapi_server_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I32 -void ffi_truapi_server_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I32 -void ffi_truapi_server_rust_future_cancel_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I32 -void ffi_truapi_server_rust_future_free_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I32 -int32_t ffi_truapi_server_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_U64 -void ffi_truapi_server_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_U64 -void ffi_truapi_server_rust_future_cancel_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_U64 -void ffi_truapi_server_rust_future_free_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_U64 -uint64_t ffi_truapi_server_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_I64 -void ffi_truapi_server_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_I64 -void ffi_truapi_server_rust_future_cancel_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_I64 -void ffi_truapi_server_rust_future_free_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_I64 -int64_t ffi_truapi_server_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_F32 -void ffi_truapi_server_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_F32 -void ffi_truapi_server_rust_future_cancel_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_F32 -void ffi_truapi_server_rust_future_free_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_F32 -float ffi_truapi_server_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_F64 -void ffi_truapi_server_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_F64 -void ffi_truapi_server_rust_future_cancel_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_F64 -void ffi_truapi_server_rust_future_free_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_F64 -double ffi_truapi_server_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_RUST_BUFFER -void ffi_truapi_server_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_RUST_BUFFER -void ffi_truapi_server_rust_future_cancel_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_RUST_BUFFER -void ffi_truapi_server_rust_future_free_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_RUST_BUFFER -RustBuffer ffi_truapi_server_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_POLL_VOID -void ffi_truapi_server_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_CANCEL_VOID -void ffi_truapi_server_rust_future_cancel_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_FREE_VOID -void ffi_truapi_server_rust_future_free_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_RUST_FUTURE_COMPLETE_VOID -void ffi_truapi_server_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_FUNC_PARSE_NAVIGATE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_FUNC_PARSE_NAVIGATE -uint16_t uniffi_truapi_server_checksum_func_parse_navigate(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_FUNC_SET_LOG_LEVEL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_FUNC_SET_LOG_LEVEL -uint16_t uniffi_truapi_server_checksum_func_set_log_level(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_ON_CORE_LOG -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_ON_CORE_LOG -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_on_core_log(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_NAVIGATE_TO -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_NAVIGATE_TO -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_navigate_to(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_PUSH_NOTIFICATION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_PUSH_NOTIFICATION -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_push_notification(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CANCEL_NOTIFICATION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CANCEL_NOTIFICATION -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_cancel_notification(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_device_permission(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_DEVICE_PERMISSION_STATUS -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_device_permission_status(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_REMOTE_PERMISSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_REMOTE_PERMISSION -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_remote_permission(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_AUTH_STATE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_AUTH_STATE_CHANGED -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_auth_state_changed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_READ -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_READ -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_read(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_WRITE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_WRITE -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_write(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_CLEAR -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CORE_STORAGE_CLEAR -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_core_storage_clear(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_CONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_CONNECT -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_chain_connect(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_SEND -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_SEND -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_chain_send(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_CLOSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CHAIN_CLOSE -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_chain_close(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CONFIRM_USER_ACTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CONFIRM_USER_ACTION -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_confirm_user_action(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOOKUP_PREIMAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOOKUP_PREIMAGE -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_lookup_preimage(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CURRENT_THEME -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CURRENT_THEME -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_current_theme(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CURRENT_LOCALE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_CURRENT_LOCALE -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_current_locale(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_FEATURE_SUPPORTED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_FEATURE_SUPPORTED -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_feature_supported(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_SUPPORTED_CHAINS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_SUPPORTED_CHAINS -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_supported_chains(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_READ -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_READ -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_read(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_WRITE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_WRITE -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_write(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_CLEAR -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_HOSTCALLBACKS_LOCAL_STORAGE_CLEAR -uint16_t uniffi_truapi_server_checksum_method_hostcallbacks_local_storage_clear(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_CREATE_ROOM -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_CREATE_ROOM -uint16_t uniffi_truapi_server_checksum_method_nativechatcallbacks_create_room(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_REGISTER_BOT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_REGISTER_BOT -uint16_t uniffi_truapi_server_checksum_method_nativechatcallbacks_register_bot(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_POST_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_POST_MESSAGE -uint16_t uniffi_truapi_server_checksum_method_nativechatcallbacks_post_message(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_LIST_ROOMS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECHATCALLBACKS_LIST_ROOMS -uint16_t uniffi_truapi_server_checksum_method_nativechatcallbacks_list_rooms(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_DEVICE_ENCRYPTION_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_DEVICE_ENCRYPTION_KEY -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_device_encryption_key(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_CLOSED -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chain_closed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_RESPONSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAIN_RESPONSE -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chain_response(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAT_ROOMS_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_CHAT_ROOMS_CHANGED -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_chat_rooms_changed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_LOCALE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_LOCALE_CHANGED -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_locale_changed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_PREIMAGE_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_PREIMAGE_CHANGED -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_preimage_changed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_THEME_CHANGED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_NOTIFY_THEME_CHANGED -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_notify_theme_changed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PERMISSION_AUTHORIZATION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PERMISSION_AUTHORIZATION_STATUS -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_permission_authorization_status(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PRODUCT_SUBTREE_PUBLIC_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PRODUCT_SUBTREE_PUBLIC_KEY -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_product_subtree_public_key(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PUBLISH_CHAT_ACTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_PUBLISH_CHAT_ACTION -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_publish_chat_action(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_RENDER_CUSTOM_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_RENDER_CUSTOM_MESSAGE -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_render_custom_message(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SESSION_CHAT_IDENTITY_KEY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SESSION_CHAT_IDENTITY_KEY -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_session_chat_identity_key(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SET_PERMISSION_AUTHORIZATION_STATUS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SET_PERMISSION_AUTHORIZATION_STATUS -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_set_permission_authorization_status(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SHUTDOWN -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_SHUTDOWN -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_shutdown(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_START_WS_BRIDGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_START_WS_BRIDGE -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_start_ws_bridge(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_STOP_WS_BRIDGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVEPRODUCTEXECUTION_STOP_WS_BRIDGE -uint16_t uniffi_truapi_server_checksum_method_nativeproductexecution_stop_ws_bridge(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_ACTIVATE_LOCAL_SESSION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_ACTIVATE_LOCAL_SESSION -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_activate_local_session(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_DISCONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_DISCONNECT -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_disconnect(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_HANDLE_SSO_REQUEST -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_HANDLE_SSO_REQUEST -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_handle_sso_request(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_LAST_STATEMENT_RENEWAL_REPORT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_LAST_STATEMENT_RENEWAL_REPORT -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_last_statement_renewal_report(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NEXT_STATEMENT_RENEWAL_DELAY -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NEXT_STATEMENT_RENEWAL_DELAY -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_next_statement_renewal_delay(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_CLOSED -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_notify_chain_closed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_RESPONSE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_NOTIFY_CHAIN_RESPONSE -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_notify_chain_response(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_OPEN_PRODUCT_EXECUTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_OPEN_PRODUCT_EXECUTION -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_open_product_execution(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_PREPARE_DISCONNECT_REQUEST -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_PREPARE_DISCONNECT_REQUEST -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_prepare_disconnect_request(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_RENEW_STATEMENT_ALLOWANCES -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_RENEW_STATEMENT_ALLOWANCES -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_renew_statement_allowances(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_START_STATEMENT_ALLOWANCE_RENEWAL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_START_STATEMENT_ALLOWANCE_RENEWAL -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_start_statement_allowance_renewal(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_TRACK_STATEMENT_RENEWAL_TARGETS -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVETRUAPIHOSTRUNTIME_TRACK_STATEMENT_RENEWAL_TARGETS -uint16_t uniffi_truapi_server_checksum_method_nativetruapihostruntime_track_statement_renewal_targets(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDERERSUBSCRIPTION_CANCEL -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDERERSUBSCRIPTION_CANCEL -uint16_t uniffi_truapi_server_checksum_method_nativecustomrenderersubscription_cancel(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_CONSTRUCTOR_NATIVETRUAPIHOSTRUNTIME_WITH_RUNTIME_CONFIG -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_CONSTRUCTOR_NATIVETRUAPIHOSTRUNTIME_WITH_RUNTIME_CONFIG -uint16_t uniffi_truapi_server_checksum_constructor_nativetruapihostruntime_with_runtime_config(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_UPDATE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_UPDATE -uint16_t uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_update(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_COMPLETE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_COMPLETE -uint16_t uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_complete(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_ERROR -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_SERVER_CHECKSUM_METHOD_NATIVECUSTOMRENDEREROBSERVER_ON_ERROR -uint16_t uniffi_truapi_server_checksum_method_nativecustomrendererobserver_on_error(void - -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_UNIFFI_CONTRACT_VERSION -#define UNIFFI_FFIDEF_FFI_TRUAPI_SERVER_UNIFFI_CONTRACT_VERSION -uint32_t ffi_truapi_server_uniffi_contract_version(void - -); -#endif - diff --git a/ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift b/ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift deleted file mode 100644 index fd7a9d325..000000000 --- a/ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift +++ /dev/null @@ -1,1373 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -// swiftlint:disable all -import Foundation - -// Depending on the consumer's build setup, the low-level FFI code -// might be in a separate module, or it might be compiled inline into -// this module. This is a bit of light hackery to work with both. -#if canImport(truapi_providerFFI) -import truapi_providerFFI -#endif - -fileprivate extension RustBuffer { - // Allocate a new buffer, copying the contents of a `UInt8` array. - init(bytes: [UInt8]) { - let rbuf = bytes.withUnsafeBufferPointer { ptr in - RustBuffer.from(ptr) - } - self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) - } - - static func empty() -> RustBuffer { - RustBuffer(capacity: 0, len:0, data: nil) - } - - static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_truapi_provider_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } - } - - // Frees the buffer in place. - // The buffer must not be used after this is called. - func deallocate() { - try! rustCall { ffi_truapi_provider_rustbuffer_free(self, $0) } - } -} - -fileprivate extension ForeignBytes { - init(bufferPointer: UnsafeBufferPointer) { - 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(_ 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 -// lifting and lowering that type from C-compatible data, and for reading and writing -// values of that type in a buffer. - -// Helper classes/extensions that don't change. -// Someday, this will be in a library of its own. - -fileprivate extension Data { - init(rustBuffer: RustBuffer) { - self.init( - bytesNoCopy: rustBuffer.data!, - count: Int(rustBuffer.len), - deallocator: .none - ) - } -} - -// Define reader functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. -// -// With external types, one swift source file needs to be able to call the read -// method on another source file's FfiConverter, but then what visibility -// should Reader have? -// - If Reader is fileprivate, then this means the read() must also -// be fileprivate, which doesn't work with external types. -// - If Reader is internal/public, we'll get compile errors since both source -// files will try define the same type. -// -// Instead, the read() method and these helper functions input a tuple of data - -fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { - (data: data, offset: 0) -} - -// Reads an integer at the current offset, in big-endian order, and advances -// the offset on success. Throws if reading the integer would move the -// offset past the end of the buffer. -fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset...size - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - if T.self == UInt8.self { - let value = reader.data[reader.offset] - reader.offset += 1 - return value as! T - } - var value: T = 0 - let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) - reader.offset = range.upperBound - return value.bigEndian -} - -// Reads an arbitrary number of bytes, to be used to read -// raw bytes, this is useful when lifting strings -fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { - let range = reader.offset..<(reader.offset+count) - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - var value = [UInt8](repeating: 0, count: count) - value.withUnsafeMutableBufferPointer({ buffer in - reader.data.copyBytes(to: buffer, from: range) - }) - reader.offset = range.upperBound - return value -} - -// Reads a float at the current offset. -fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return Float(bitPattern: try readInt(&reader)) -} - -// Reads a float at the current offset. -fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return Double(bitPattern: try readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { - return reader.offset < reader.data.count -} - -// Define writer functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. See the above discussion on Readers for details. - -fileprivate func createWriter() -> [UInt8] { - return [] -} - -fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { - writer.append(contentsOf: byteArr) -} - -// Writes an integer in big-endian order. -// -// Warning: make sure what you are trying to write -// is in the correct type! -fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous to the Rust trait of the same name. -fileprivate protocol FfiConverter { - associatedtype FfiType - associatedtype SwiftType - - static func lift(_ value: FfiType) throws -> SwiftType - static func lower(_ value: SwiftType) -> FfiType - static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType - static func write(_ value: SwiftType, into buf: inout [UInt8]) -} - -// Types conforming to `Primitive` pass themselves directly over the FFI. -fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } - -extension FfiConverterPrimitive { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> FfiType { - return value - } -} - -// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. -// Used for complex types where it's hard to write a custom lift/lower. -fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lift(_ buf: RustBuffer) throws -> SwiftType { - var reader = createReader(data: Data(rustBuffer: buf)) - let value = try read(from: &reader) - if hasRemaining(reader) { - throw UniffiInternalError.incompleteData - } - buf.deallocate() - return value - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public static func lower(_ value: SwiftType) -> RustBuffer { - var writer = createWriter() - write(value, into: &writer) - return RustBuffer(bytes: writer) - } -} -// An error type for FFI errors. These errors occur at the UniFFI level, not -// the library level. -fileprivate enum UniffiInternalError: LocalizedError { - case bufferOverflow - case incompleteData - case unexpectedOptionalTag - case unexpectedEnumCase - case unexpectedNullPointer - case unexpectedRustCallStatusCode - case unexpectedRustCallError - case unexpectedStaleHandle - case rustPanic(_ message: String) - - public var errorDescription: String? { - switch self { - case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" - case .incompleteData: return "The buffer still has data after lifting its containing value" - case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" - case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" - case .unexpectedNullPointer: return "Raw pointer value was null" - case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" - case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" - case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" - case let .rustPanic(message): return message - } - } -} - -fileprivate extension NSLock { - func withLock(f: () throws -> T) rethrows -> T { - self.lock() - defer { self.unlock() } - return try f() - } -} - -fileprivate let CALL_SUCCESS: Int8 = 0 -fileprivate let CALL_ERROR: Int8 = 1 -fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 -fileprivate let CALL_CANCELLED: Int8 = 3 - -fileprivate extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer.init( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - let neverThrow: ((RustBuffer) throws -> Never)? = nil - return try makeRustCall(callback, errorHandler: neverThrow) -} - -private func rustCallWithError( - _ errorHandler: @escaping (RustBuffer) throws -> E, - _ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: errorHandler) -} - -private func makeRustCall( - _ callback: (UnsafeMutablePointer) -> T, - errorHandler: ((RustBuffer) throws -> E)? -) throws -> T { - uniffiEnsureTruapiProviderInitialized() - var callStatus = RustCallStatus.init() - let returnedVal = callback(&callStatus) - try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) - return returnedVal -} - -private func uniffiCheckCallStatus( - callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> E)? -) throws { - switch callStatus.code { - case CALL_SUCCESS: - return - - case CALL_ERROR: - if let errorHandler = errorHandler { - throw try errorHandler(callStatus.errorBuf) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.unexpectedRustCallError - } - - case CALL_UNEXPECTED_ERROR: - // When the rust code sees a panic, it tries to construct a RustBuffer - // with the message. But if that code panics, then it just sends back - // an empty buffer. - if callStatus.errorBuf.len > 0 { - throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - case CALL_CANCELLED: - fatalError("Cancellation not supported yet") - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -private func uniffiTraitInterfaceCall( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> () -) { - do { - try writeReturn(makeCall()) - } catch let error { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) - } -} - -private func uniffiTraitInterfaceCallWithError( - callStatus: UnsafeMutablePointer, - makeCall: () throws -> T, - writeReturn: (T) -> (), - lowerError: (E) -> RustBuffer -) { - do { - try writeReturn(makeCall()) - } catch let error as E { - callStatus.pointee.code = CALL_ERROR - callStatus.pointee.errorBuf = lowerError(error) - } catch { - callStatus.pointee.code = CALL_UNEXPECTED_ERROR - 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: @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 = UNIFFI_HANDLEMAP_INITIAL - - func insert(obj: T) -> UInt64 { - lock.withLock { - 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 { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - 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 { - guard let obj = map.removeValue(forKey: handle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return obj - } - } - - var count: Int { - get { - map.count - } - } -} - - -// Public interface members begin here. -// Magic number for the Rust proxy to call using the same mechanism as every other method, -// to free the callback once it's dropped by Rust. -private let IDX_CALLBACK_FREE: Int32 = 0 -// Callback return codes -private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 -private let UNIFFI_CALLBACK_ERROR: Int32 = 1 -private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterString: FfiConverter { - typealias SwiftType = String - typealias FfiType = RustBuffer - - public static func lift(_ value: RustBuffer) throws -> String { - defer { - value.deallocate() - } - if value.data == nil { - return String() - } - let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) - // 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 { - return value.utf8CString.withUnsafeBufferPointer { ptr in - // The swift string gives us int8_t, we want uint8_t. - ptr.withMemoryRebound(to: UInt8.self) { ptr in - // The swift string gives us a trailing null byte, we don't want it. - let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) - return RustBuffer.from(buf) - } - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { - let len: Int32 = try readInt(&buf) - // 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]) { - let len = Int32(value.utf8.count) - writeInt(&buf, len) - writeBytes(&buf, value.utf8) - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterData: FfiConverterRustBuffer { - typealias SwiftType = Data - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { - let len: Int32 = try readInt(&buf) - return Data(try readBytes(&buf, count: Int(len))) - } - - public static func write(_ value: Data, into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - writeBytes(&buf, value) - } -} - - - - -/** - * A live JSON-RPC connection: a raw string pipe to one chain. - */ -public protocol ChainConnectionProtocol: AnyObject, Sendable { - - /** - * Close the connection; the listener's `on_closed` fires once the stream - * ends. - * - * NOT named `close`: uniffi's generated Kotlin object already implements - * `AutoCloseable.close()` for handle disposal, so an exported `close` - * produces two methods with the same signature and the module does not - * compile ("Conflicting overloads"). - */ - func disconnect() - - /** - * Queue a JSON-RPC request string. - */ - func send(request: String) - -} -/** - * A live JSON-RPC connection: a raw string pipe to one chain. - */ -open class ChainConnection: ChainConnectionProtocol, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_provider_fn_clone_chainconnection(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_provider_fn_free_chainconnection(handle, $0) } - } - - - - - /** - * Close the connection; the listener's `on_closed` fires once the stream - * ends. - * - * NOT named `close`: uniffi's generated Kotlin object already implements - * `AutoCloseable.close()` for handle disposal, so an exported `close` - * produces two methods with the same signature and the module does not - * compile ("Conflicting overloads"). - */ -open func disconnect() {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_provider_fn_method_chainconnection_disconnect( - self.uniffiCloneHandle(),uniffiCallStatus - ) -} -} - - /** - * Queue a JSON-RPC request string. - */ -open func send(request: String) {try! rustCall() { - uniffiCallStatus in - uniffi_truapi_provider_fn_method_chainconnection_send( - self.uniffiCloneHandle(), - FfiConverterString.lower(request),uniffiCallStatus - ) -} -} - - - -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainConnection: FfiConverter { - typealias FfiType = UInt64 - typealias SwiftType = ChainConnection - - public static func lift(_ handle: UInt64) throws -> ChainConnection { - return ChainConnection(unsafeFromHandle: handle) - } - - public static func lower(_ value: ChainConnection) -> UInt64 { - return value.uniffiCloneHandle() - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainConnection { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: ChainConnection, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainConnection_lift(_ handle: UInt64) throws -> ChainConnection { - return try FfiConverterTypeChainConnection.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainConnection_lower(_ value: ChainConnection) -> UInt64 { - return FfiConverterTypeChainConnection.lower(value) -} - - - - - - -/** - * Sink for a connection's inbound JSON-RPC responses and notifications, - * implemented on the foreign (Swift) side. - */ -public protocol ChainMessageListener: AnyObject, Sendable { - - /** - * Called for each JSON-RPC response or notification string. - */ - func onMessage(message: String) throws - - /** - * Called once the connection has closed, whichever way it ended. - */ - func onClosed(reason: ChainCloseReason) throws - -} -/** - * Sink for a connection's inbound JSON-RPC responses and notifications, - * implemented on the foreign (Swift) side. - */ -open class ChainMessageListenerImpl: ChainMessageListener, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_provider_fn_clone_chainmessagelistener(self.handle, $0) } - } - // No primary constructor declared for this class. - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_provider_fn_free_chainmessagelistener(handle, $0) } - } - - - - - /** - * Called for each JSON-RPC response or notification string. - */ -open func onMessage(message: String)throws {try rustCallWithError(FfiConverterTypeChainProviderError_lift) { - uniffiCallStatus in - uniffi_truapi_provider_fn_method_chainmessagelistener_on_message( - self.uniffiCloneHandle(), - FfiConverterString.lower(message),uniffiCallStatus - ) -} -} - - /** - * Called once the connection has closed, whichever way it ended. - */ -open func onClosed(reason: ChainCloseReason)throws {try rustCallWithError(FfiConverterTypeChainProviderError_lift) { - uniffiCallStatus in - uniffi_truapi_provider_fn_method_chainmessagelistener_on_closed( - self.uniffiCloneHandle(), - FfiConverterTypeChainCloseReason_lower(reason),uniffiCallStatus - ) -} -} - - - -} - - - -// Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceChainMessageListener { - - // Create the VTable using a series of closures. - // Swift automatically converts these into C callback functions. - // - // Store the vtable directly. - static let vtable: UniffiVTableCallbackInterfaceChainMessageListener = UniffiVTableCallbackInterfaceChainMessageListener( - uniffiFree: { (uniffiHandle: UInt64) -> () in - do { - try FfiConverterTypeChainMessageListener.handleMap.remove(handle: uniffiHandle) - } catch { - print("Uniffi callback interface ChainMessageListener: handle missing in uniffiFree") - } - }, - uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in - do { - return try FfiConverterTypeChainMessageListener.handleMap.clone(handle: uniffiHandle) - } catch { - fatalError("Uniffi callback interface ChainMessageListener: handle missing in uniffiClone") - } - }, - onMessage: { ( - uniffiHandle: UInt64, - message: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeChainMessageListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.onMessage( - message: try FfiConverterString.lift(message) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeChainProviderError_lower - ) - }, - onClosed: { ( - uniffiHandle: UInt64, - reason: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeChainMessageListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.onClosed( - reason: try FfiConverterTypeChainCloseReason_lift(reason) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCallWithError( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn, - lowerError: FfiConverterTypeChainProviderError_lower - ) - } - ) - - // Rust stores this pointer for future callback invocations, so it must live - // for the process lifetime (not just for the init function call). - // - // `nonisolated(unsafe)` is needed under Swift 6 strict concurrency. - // This is safe because the pointee is initialized once during static init - // and never mutated by either side of the FFI. Its fields are C function pointers. - nonisolated(unsafe) static let vtablePtr: UnsafePointer = { - let ptr = UnsafeMutablePointer.allocate(capacity: 1) - ptr.initialize(to: vtable) - return UnsafePointer(ptr) - }() -} - -private func uniffiCallbackInitChainMessageListener() { - uniffi_truapi_provider_fn_init_callback_vtable_chainmessagelistener(UniffiCallbackInterfaceChainMessageListener.vtablePtr) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainMessageListener: FfiConverter { - fileprivate static let handleMap = UniffiHandleMap() - - typealias FfiType = UInt64 - typealias SwiftType = ChainMessageListener - - public static func lift(_ handle: UInt64) throws -> ChainMessageListener { - if ((handle & 1) == 0) { - // Rust-generated handle, construct a new class that uses the handle to implement the - // interface - return ChainMessageListenerImpl(unsafeFromHandle: handle) - } else { - // Swift-generated handle, get the object from the handle map - return try handleMap.remove(handle: handle) - } - } - - public static func lower(_ value: ChainMessageListener) -> UInt64 { - if let rustImpl = value as? ChainMessageListenerImpl { - // Rust-implemented object. Clone the handle and return it - return rustImpl.uniffiCloneHandle() - } else { - // Swift object, generate a new vtable handle and return that. - return handleMap.insert(obj: value) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainMessageListener { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: ChainMessageListener, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainMessageListener_lift(_ handle: UInt64) throws -> ChainMessageListener { - return try FfiConverterTypeChainMessageListener.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainMessageListener_lower(_ value: ChainMessageListener) -> UInt64 { - return FfiConverterTypeChainMessageListener.lower(value) -} - - - - - - -/** - * Embedded-smoldot chain provider. Construct one per process and share it; - * every connection runs on the single embedded light client. - */ -public protocol ChainProviderProtocol: AnyObject, Sendable { - - /** - * Open a connection to the chain identified by `genesis_hash` (32 bytes). - * The network is resolved from the catalog; responses are delivered to - * `listener` until the connection closes. - */ - func connect(genesisHash: Data, listener: ChainMessageListener) throws -> ChainConnection - -} -/** - * Embedded-smoldot chain provider. Construct one per process and share it; - * every connection runs on the single embedded light client. - */ -open class ChainProvider: ChainProviderProtocol, @unchecked Sendable { - fileprivate let handle: UInt64 - - /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public struct NoHandle { - public init() {} - } - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - required public init(unsafeFromHandle handle: UInt64) { - self.handle = handle - } - - // This constructor can be used to instantiate a fake object. - // - 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 handle the FFI lower functions will crash. -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public init(noHandle: NoHandle) { - self.handle = 0 - } - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif - public func uniffiCloneHandle() -> UInt64 { - return try! rustCall { uniffi_truapi_provider_fn_clone_chainprovider(self.handle, $0) } - } - /** - * Create a provider backed by the bundled network catalog. - */ -public convenience init() { - let handle = - try! rustCall() { - uniffiCallStatus in - uniffi_truapi_provider_fn_constructor_chainprovider_new(uniffiCallStatus - ) -} - self.init(unsafeFromHandle: handle) -} - - deinit { - if handle == 0 { - // Mock objects have handle=0 don't try to free them - return - } - - try! rustCall { uniffi_truapi_provider_fn_free_chainprovider(handle, $0) } - } - - - - - /** - * Open a connection to the chain identified by `genesis_hash` (32 bytes). - * The network is resolved from the catalog; responses are delivered to - * `listener` until the connection closes. - */ -open func connect(genesisHash: Data, listener: ChainMessageListener)throws -> ChainConnection { - return try FfiConverterTypeChainConnection_lift(try rustCallWithError(FfiConverterTypeChainProviderError_lift) { - uniffiCallStatus in - uniffi_truapi_provider_fn_method_chainprovider_connect( - self.uniffiCloneHandle(), - FfiConverterData.lower(genesisHash), - FfiConverterTypeChainMessageListener_lower(listener),uniffiCallStatus - ) -}) -} - - - -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainProvider: FfiConverter { - typealias FfiType = UInt64 - typealias SwiftType = ChainProvider - - public static func lift(_ handle: UInt64) throws -> ChainProvider { - return ChainProvider(unsafeFromHandle: handle) - } - - public static func lower(_ value: ChainProvider) -> UInt64 { - return value.uniffiCloneHandle() - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainProvider { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - public static func write(_ value: ChainProvider, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainProvider_lift(_ handle: UInt64) throws -> ChainProvider { - return try FfiConverterTypeChainProvider.lift(handle) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainProvider_lower(_ value: ChainProvider) -> UInt64 { - return FfiConverterTypeChainProvider.lower(value) -} - - - - -/** - * Why the pump stopped delivering a connection's responses. - * - * This says what the core observed, not whether a reconnect is wanted. On the - * light-client path a response stream ends only when the connection is closed, - * including by this host's own `disconnect()` or by dropping the handle, so - * `StreamEnded` is usually the host's own teardown coming back to it. A host - * that reconnects on it without checking its own intent will reconnect to a - * connection it deliberately closed. - * - * New variants may be added, so a Swift host should carry an `@unknown - * default` and a Kotlin host an `else` branch. - * - * Reconnecting is done from another thread, and a serial one: a listener - * callback runs on the pump thread, and `ChainProvider::connect` refuses to - * run there. Hopping to a concurrent queue lets reconnects run in parallel, - * and each one costs a thread plus a chain-spec parse. - * - * Do not re-queue work with `send` from `on_closed`. By then the connection - * is closed either way: `close()` is what ended the stream on `StreamEnded`, - * and the pump closes it before reporting `ListenerFailed`. `send` on a - * closed connection is dropped silently, with no error and no frame for the - * request's id, so a consumer correlating by id would wait forever. From `on_message`, where the - * connection is still open, `send` behaves normally. `disconnect` is - * idempotent and safe to call from either callback. - */ - -public enum ChainCloseReason: Equatable, Hashable { - - /** - * The response stream ended. - * - * Every connection this crate hands a host runs on the embedded light - * client, and that stream ends only when the connection is closed, so in - * practice this is your own teardown arriving back: `disconnect()`, or - * dropping the handle. It is not a report that the peer went away. - */ - case streamEnded - /** - * This listener returned an error from `on_message`, so the connection was - * closed under it. - * - * A listener that rejects frames while it is shutting down reports this - * even when the host asked for the teardown: `on_message` blocks in - * foreign code, so a `disconnect()` can land while a frame is already in - * flight, and rejecting that frame is a listener failure like any other. - */ - case listenerFailed( - /** - * What the listener reported, bounded to 256 characters. For logs - * and diagnostics: a - * host that needs to branch on its own failure modes should track them - * where it raised them. - */reason: String - ) - - - - - -} - -#if compiler(>=6) -extension ChainCloseReason: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainCloseReason: FfiConverterRustBuffer { - typealias SwiftType = ChainCloseReason - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainCloseReason { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .streamEnded - - case 2: return .listenerFailed(reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChainCloseReason, into buf: inout [UInt8]) { - switch value { - - - case .streamEnded: - writeInt(&buf, Int32(1)) - - - case let .listenerFailed(reason): - writeInt(&buf, Int32(2)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainCloseReason_lift(_ buf: RustBuffer) throws -> ChainCloseReason { - return try FfiConverterTypeChainCloseReason.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainCloseReason_lower(_ value: ChainCloseReason) -> RustBuffer { - return FfiConverterTypeChainCloseReason.lower(value) -} - - - -/** - * Errors surfaced to the foreign caller. - */ -public -enum ChainProviderError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { - - - - /** - * The chain could not be connected (unknown genesis, transport failure). - */ - case Connect( - /** - * Human-readable failure reason. - */reason: String - ) - /** - * The genesis hash was not exactly 32 bytes. - */ - case BadGenesis - /** - * The host's listener failed in a way it did not declare. - */ - case Listener( - /** - * Human-readable failure reason. - */reason: String - ) - - - - - - - public var errorDescription: String? { - String(reflecting: self) - } - -} - -#if compiler(>=6) -extension ChainProviderError: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChainProviderError: FfiConverterRustBuffer { - typealias SwiftType = ChainProviderError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChainProviderError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .Connect( - reason: try FfiConverterString.read(from: &buf) - ) - case 2: return .BadGenesis - case 3: return .Listener( - reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ChainProviderError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .Connect(reason): - writeInt(&buf, Int32(1)) - FfiConverterString.write(reason, into: &buf) - - - case .BadGenesis: - writeInt(&buf, Int32(2)) - - - case let .Listener(reason): - writeInt(&buf, Int32(3)) - FfiConverterString.write(reason, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainProviderError_lift(_ buf: RustBuffer) throws -> ChainProviderError { - return try FfiConverterTypeChainProviderError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeChainProviderError_lower(_ value: ChainProviderError) -> RustBuffer { - return FfiConverterTypeChainProviderError.lower(value) -} - -private enum InitializationResult { - case ok - case contractVersionMismatch - case apiChecksumMismatch -} -// Use a global variable to perform the versioning checks. Swift ensures that -// the code inside is only computed once. -private let initializationResult: InitializationResult = { - // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 30 - // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_truapi_provider_uniffi_contract_version() - if bindings_contract_version != scaffolding_contract_version { - return InitializationResult.contractVersionMismatch - } - if (uniffi_truapi_provider_checksum_method_chainconnection_disconnect() != 40440) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_provider_checksum_method_chainconnection_send() != 52883) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_provider_checksum_method_chainmessagelistener_on_message() != 2156) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_provider_checksum_method_chainmessagelistener_on_closed() != 45188) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_provider_checksum_method_chainprovider_connect() != 16550) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_truapi_provider_checksum_constructor_chainprovider_new() != 37203) { - return InitializationResult.apiChecksumMismatch - } - - uniffiCallbackInitChainMessageListener() - return InitializationResult.ok -}() - -// Make the ensure init function public so that other modules which have external type references to -// our types can call it. -public func uniffiEnsureTruapiProviderInitialized() { - switch initializationResult { - case .ok: - break - case .contractVersionMismatch: - fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") - case .apiChecksumMismatch: - fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } -} - -// swiftlint:enable all \ No newline at end of file diff --git a/ios/truapi-provider/Sources/truapi_providerFFI/include/module.modulemap b/ios/truapi-provider/Sources/truapi_providerFFI/include/module.modulemap deleted file mode 100644 index cddb60daa..000000000 --- a/ios/truapi-provider/Sources/truapi_providerFFI/include/module.modulemap +++ /dev/null @@ -1,7 +0,0 @@ -module truapi_providerFFI { - header "truapi_providerFFI.h" - export * - use "Darwin" - use "_Builtin_stdbool" - use "_Builtin_stdint" -} \ No newline at end of file diff --git a/ios/truapi-provider/Sources/truapi_providerFFI/include/truapi_providerFFI.h b/ios/truapi-provider/Sources/truapi_providerFFI/include/truapi_providerFFI.h deleted file mode 100644 index 0409984ed..000000000 --- a/ios/truapi-provider/Sources/truapi_providerFFI/include/truapi_providerFFI.h +++ /dev/null @@ -1,638 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! - -#pragma once - -#include -#include -#include - -// The following structs are used to implement the lowest level -// of the FFI, and thus useful to multiple uniffied crates. -// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. -#ifdef UNIFFI_SHARED_H - // We also try to prevent mixing versions of shared uniffi header structs. - // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 - #ifndef UNIFFI_SHARED_HEADER_V4 - #error Combining helper code from multiple versions of uniffi is not supported - #endif // ndef UNIFFI_SHARED_HEADER_V4 -#else -#define UNIFFI_SHARED_H -#define UNIFFI_SHARED_HEADER_V4 -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ - -typedef struct RustBuffer -{ - uint64_t capacity; - uint64_t len; - uint8_t *_Nullable data; -} RustBuffer; - -typedef struct ForeignBytes -{ - int32_t len; - const uint8_t *_Nullable data; -} ForeignBytes; - -// Error definitions -typedef struct RustCallStatus { - int8_t code; - RustBuffer errorBuf; -} RustCallStatus; - -// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ -// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ -#endif // def UNIFFI_SHARED_H -#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK -typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK -typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE -typedef void (*UniffiCallbackInterfaceFree)(uint64_t - ); - -#endif -#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; - UniffiForeignFutureDroppedCallback _Nonnull free; -} UniffiForeignFutureDroppedCallbackStruct; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 -typedef struct UniffiForeignFutureResultU8 { - uint8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 -typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 -typedef struct UniffiForeignFutureResultI8 { - int8_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI8; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 -typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 -typedef struct UniffiForeignFutureResultU16 { - uint16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 -typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 -typedef struct UniffiForeignFutureResultI16 { - int16_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI16; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 -typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 -typedef struct UniffiForeignFutureResultU32 { - uint32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 -typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 -typedef struct UniffiForeignFutureResultI32 { - int32_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 -typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 -typedef struct UniffiForeignFutureResultU64 { - uint64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultU64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 -typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 -typedef struct UniffiForeignFutureResultI64 { - int64_t returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultI64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 -typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 -typedef struct UniffiForeignFutureResultF32 { - float returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF32; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 -typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 -typedef struct UniffiForeignFutureResultF64 { - double returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultF64; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 -typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER -typedef struct UniffiForeignFutureResultRustBuffer { - RustBuffer returnValue; - RustCallStatus callStatus; -} UniffiForeignFutureResultRustBuffer; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER -typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer - ); - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID -typedef struct UniffiForeignFutureResultVoid { - RustCallStatus callStatus; -} UniffiForeignFutureResultVoid; - -#endif -#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID -typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER_METHOD0 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER_METHOD0 -typedef void (*UniffiCallbackInterfaceChainMessageListenerMethod0)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER_METHOD1 -#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER_METHOD1 -typedef void (*UniffiCallbackInterfaceChainMessageListenerMethod1)(uint64_t, RustBuffer, void* _Nonnull, - RustCallStatus *_Nonnull uniffiCallStatus - ); - -#endif -#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER -#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_CHAIN_MESSAGE_LISTENER -typedef struct UniffiVTableCallbackInterfaceChainMessageListener { - UniffiCallbackInterfaceFree _Nonnull uniffiFree; - UniffiCallbackInterfaceClone _Nonnull uniffiClone; - UniffiCallbackInterfaceChainMessageListenerMethod0 _Nonnull onMessage; - UniffiCallbackInterfaceChainMessageListenerMethod1 _Nonnull onClosed; -} UniffiVTableCallbackInterfaceChainMessageListener; - -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINCONNECTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINCONNECTION -uint64_t uniffi_truapi_provider_fn_clone_chainconnection(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINCONNECTION -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINCONNECTION -void uniffi_truapi_provider_fn_free_chainconnection(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINCONNECTION_DISCONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINCONNECTION_DISCONNECT -void uniffi_truapi_provider_fn_method_chainconnection_disconnect(uint64_t ptr, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINCONNECTION_SEND -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINCONNECTION_SEND -void uniffi_truapi_provider_fn_method_chainconnection_send(uint64_t ptr, RustBuffer request, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINMESSAGELISTENER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINMESSAGELISTENER -uint64_t uniffi_truapi_provider_fn_clone_chainmessagelistener(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINMESSAGELISTENER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINMESSAGELISTENER -void uniffi_truapi_provider_fn_free_chainmessagelistener(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_INIT_CALLBACK_VTABLE_CHAINMESSAGELISTENER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_INIT_CALLBACK_VTABLE_CHAINMESSAGELISTENER -void uniffi_truapi_provider_fn_init_callback_vtable_chainmessagelistener(const UniffiVTableCallbackInterfaceChainMessageListener* _Nonnull vtable -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINMESSAGELISTENER_ON_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINMESSAGELISTENER_ON_MESSAGE -void uniffi_truapi_provider_fn_method_chainmessagelistener_on_message(uint64_t ptr, RustBuffer message, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINMESSAGELISTENER_ON_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINMESSAGELISTENER_ON_CLOSED -void uniffi_truapi_provider_fn_method_chainmessagelistener_on_closed(uint64_t ptr, RustBuffer reason, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINPROVIDER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CLONE_CHAINPROVIDER -uint64_t uniffi_truapi_provider_fn_clone_chainprovider(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINPROVIDER -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_FREE_CHAINPROVIDER -void uniffi_truapi_provider_fn_free_chainprovider(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CONSTRUCTOR_CHAINPROVIDER_NEW -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_CONSTRUCTOR_CHAINPROVIDER_NEW -uint64_t uniffi_truapi_provider_fn_constructor_chainprovider_new(RustCallStatus *_Nonnull out_status - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINPROVIDER_CONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_FN_METHOD_CHAINPROVIDER_CONNECT -uint64_t uniffi_truapi_provider_fn_method_chainprovider_connect(uint64_t ptr, RustBuffer genesis_hash, uint64_t listener, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_ALLOC -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_ALLOC -RustBuffer ffi_truapi_provider_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_FROM_BYTES -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_FROM_BYTES -RustBuffer ffi_truapi_provider_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_FREE -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_FREE -void ffi_truapi_provider_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_RESERVE -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUSTBUFFER_RESERVE -RustBuffer ffi_truapi_provider_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U8 -void ffi_truapi_provider_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U8 -void ffi_truapi_provider_rust_future_cancel_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U8 -void ffi_truapi_provider_rust_future_free_u8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U8 -uint8_t ffi_truapi_provider_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I8 -void ffi_truapi_provider_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I8 -void ffi_truapi_provider_rust_future_cancel_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I8 -void ffi_truapi_provider_rust_future_free_i8(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I8 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I8 -int8_t ffi_truapi_provider_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U16 -void ffi_truapi_provider_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U16 -void ffi_truapi_provider_rust_future_cancel_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U16 -void ffi_truapi_provider_rust_future_free_u16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U16 -uint16_t ffi_truapi_provider_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I16 -void ffi_truapi_provider_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I16 -void ffi_truapi_provider_rust_future_cancel_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I16 -void ffi_truapi_provider_rust_future_free_i16(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I16 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I16 -int16_t ffi_truapi_provider_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U32 -void ffi_truapi_provider_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U32 -void ffi_truapi_provider_rust_future_cancel_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U32 -void ffi_truapi_provider_rust_future_free_u32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U32 -uint32_t ffi_truapi_provider_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I32 -void ffi_truapi_provider_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I32 -void ffi_truapi_provider_rust_future_cancel_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I32 -void ffi_truapi_provider_rust_future_free_i32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I32 -int32_t ffi_truapi_provider_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_U64 -void ffi_truapi_provider_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_U64 -void ffi_truapi_provider_rust_future_cancel_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_U64 -void ffi_truapi_provider_rust_future_free_u64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_U64 -uint64_t ffi_truapi_provider_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_I64 -void ffi_truapi_provider_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_I64 -void ffi_truapi_provider_rust_future_cancel_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_I64 -void ffi_truapi_provider_rust_future_free_i64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_I64 -int64_t ffi_truapi_provider_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_F32 -void ffi_truapi_provider_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_F32 -void ffi_truapi_provider_rust_future_cancel_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_F32 -void ffi_truapi_provider_rust_future_free_f32(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_F32 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_F32 -float ffi_truapi_provider_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_F64 -void ffi_truapi_provider_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_F64 -void ffi_truapi_provider_rust_future_cancel_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_F64 -void ffi_truapi_provider_rust_future_free_f64(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_F64 -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_F64 -double ffi_truapi_provider_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_RUST_BUFFER -void ffi_truapi_provider_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_RUST_BUFFER -void ffi_truapi_provider_rust_future_cancel_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_RUST_BUFFER -void ffi_truapi_provider_rust_future_free_rust_buffer(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_RUST_BUFFER -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_RUST_BUFFER -RustBuffer ffi_truapi_provider_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_POLL_VOID -void ffi_truapi_provider_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_CANCEL_VOID -void ffi_truapi_provider_rust_future_cancel_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_FREE_VOID -void ffi_truapi_provider_rust_future_free_void(uint64_t handle -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_VOID -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_RUST_FUTURE_COMPLETE_VOID -void ffi_truapi_provider_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINCONNECTION_DISCONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINCONNECTION_DISCONNECT -uint16_t uniffi_truapi_provider_checksum_method_chainconnection_disconnect(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINCONNECTION_SEND -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINCONNECTION_SEND -uint16_t uniffi_truapi_provider_checksum_method_chainconnection_send(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINMESSAGELISTENER_ON_MESSAGE -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINMESSAGELISTENER_ON_MESSAGE -uint16_t uniffi_truapi_provider_checksum_method_chainmessagelistener_on_message(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINMESSAGELISTENER_ON_CLOSED -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINMESSAGELISTENER_ON_CLOSED -uint16_t uniffi_truapi_provider_checksum_method_chainmessagelistener_on_closed(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINPROVIDER_CONNECT -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_METHOD_CHAINPROVIDER_CONNECT -uint16_t uniffi_truapi_provider_checksum_method_chainprovider_connect(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_CONSTRUCTOR_CHAINPROVIDER_NEW -#define UNIFFI_FFIDEF_UNIFFI_TRUAPI_PROVIDER_CHECKSUM_CONSTRUCTOR_CHAINPROVIDER_NEW -uint16_t uniffi_truapi_provider_checksum_constructor_chainprovider_new(void - -); -#endif -#ifndef UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_UNIFFI_CONTRACT_VERSION -#define UNIFFI_FFIDEF_FFI_TRUAPI_PROVIDER_UNIFFI_CONTRACT_VERSION -uint32_t ffi_truapi_provider_uniffi_contract_version(void - -); -#endif - diff --git a/rust/crates/truapi-server/src/generated/dispatcher.rs b/rust/crates/truapi-server/src/generated/dispatcher.rs deleted file mode 100644 index e23c58ce0..000000000 --- a/rust/crates/truapi-server/src/generated/dispatcher.rs +++ /dev/null @@ -1,2736 +0,0 @@ -//! Wire dispatcher for the unified `TrUApi` trait. -//! -//! Auto-generated by truapi-codegen. Do not edit. - -// Responses are downgraded to the caller's version uniformly, including -// the methods whose payload is unit and for which the conversion is a -// no-op. -#![allow(clippy::unit_arg)] - -use std::sync::Arc; - -use parity_scale_codec::Decode; - -use truapi::CallContext; -use truapi::api::{ - Account, Chain, Chat, CoinPayment, Entropy, LocalStorage, Locale, Notifications, Payment, - Permissions, Preimage, ResourceAllocation, Signing, StatementStore, System, Theme, -}; -use truapi::versioned::{self, Versioned}; -use truapi_platform::ProductExecutionKind; - -use crate::dispatcher::Dispatcher; -use crate::frame::downgrade_call_error; -use crate::frame::encode_versioned_err_payload; -use crate::frame::encode_versioned_interrupt_payload; -use crate::frame::encode_versioned_ok_payload; -use crate::frame::encode_versioned_unit_ok_payload; -use crate::generated::wire_table; -use crate::subscription::{HostInitiatedSubscriptionManager, subscription_stream}; -use crate::transport::Transport; - -/// Register every TrUAPI method with the dispatcher. -pub fn register

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: truapi::api::TrUApi + 'static, -{ - register_account(dispatcher, host.clone()); - register_chain(dispatcher, host.clone()); - register_chat(dispatcher, host.clone()); - register_coin_payment(dispatcher, host.clone()); - register_entropy(dispatcher, host.clone()); - register_local_storage(dispatcher, host.clone()); - register_locale(dispatcher, host.clone()); - register_notifications(dispatcher, host.clone()); - register_payment(dispatcher, host.clone()); - register_permissions(dispatcher, host.clone()); - register_preimage(dispatcher, host.clone()); - register_resource_allocation(dispatcher, host.clone()); - register_signing(dispatcher, host.clone()); - register_statement_store(dispatcher, host.clone()); - register_system(dispatcher, host.clone()); - register_theme(dispatcher, host); -} - -/// Start the host-initiated `chat_custom_message_render` subscription. -pub(crate) fn chat_custom_message_render( - subscriptions: &HostInitiatedSubscriptionManager, - transport: Arc, - request: versioned::chat::ProductChatCustomMessageRenderRequest, -) -> truapi::Subscription< - Result, -> { - subscriptions.start( - wire_table::CHAT_CUSTOM_MESSAGE_RENDER, - parity_scale_codec::Encode::encode(&request), - transport, - ) -} - -fn register_account

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Account + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_subscription( - wire_table::ACCOUNT_CONNECTION_STATUS_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let _ = bytes; - let cx = CallContext::with_request_id(request_id.clone()); - let stream = host.connection_status_subscribe(&cx).await; - Ok(subscription_stream::< - versioned::account::HostAccountConnectionStatusSubscribeItem, - _, - >(stream)) - }) - }, - ); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_GET_ACCOUNT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountGetRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountGetResponse = match host.get_account(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_GET_ACCOUNT_ALIAS, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountGetAliasRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountGetAliasResponse = match host.get_account_alias(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_CREATE_ACCOUNT_PROOF, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountCreateProofRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountCreateProofResponse = match host.create_account_proof(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_SIGN_VRF, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountSignVrfRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountSignVrfResponse = match host.sign_vrf(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_REGISTER_RING_VRF_KEY, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountRegisterRingVrfKeyRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountRegisterRingVrfKeyResponse = match host.register_ring_vrf_key(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_LIST_RING_VRF_KEYS, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountListRingVrfKeysRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountListRingVrfKeysResponse = match host.list_ring_vrf_keys(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_RING_VRF_SIGN, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostAccountRingVrfSignRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostAccountRingVrfSignResponse = match host.ring_vrf_sign(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_GET_LEGACY_ACCOUNTS, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostGetLegacyAccountsRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostGetLegacyAccountsResponse = match host.get_legacy_accounts(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::ACCOUNT_GET_USER_ID, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostGetUserIdRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostGetUserIdResponse = match host.get_user_id(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::ACCOUNT_REQUEST_LOGIN, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::account::HostRequestLoginRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::account::HostRequestLoginResponse = match host.request_login(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_chain

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Chain + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_subscription( - wire_table::CHAIN_FOLLOW_HEAD_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadFollowRequest = - match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(_) => return Err(Vec::new()), - }; - let cx = CallContext::with_request_id(request_id.clone()); - let stream = host.follow_head_subscribe(&cx, request).await; - Ok(subscription_stream::< - versioned::chain::RemoteChainHeadFollowItem, - _, - >(stream)) - }) - }, - ); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_HEAD_HEADER, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadHeaderRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadHeaderResponse = match host.get_head_header(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_HEAD_BODY, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadBodyRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadBodyResponse = match host.get_head_body(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_HEAD_STORAGE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadStorageRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadStorageResponse = match host.get_head_storage(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_CALL_HEAD, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadCallRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadCallResponse = match host.call_head(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_UNPIN_HEAD, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadUnpinRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadUnpinResponse = match host.unpin_head(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_CONTINUE_HEAD, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadContinueRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadContinueResponse = match host.continue_head(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_STOP_HEAD_OPERATION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainHeadStopOperationRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainHeadStopOperationResponse = match host.stop_head_operation(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_SPEC_GENESIS_HASH, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainSpecGenesisHashRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainSpecGenesisHashResponse = match host.get_spec_genesis_hash(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_SPEC_CHAIN_NAME, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainSpecChainNameRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainSpecChainNameResponse = match host.get_spec_chain_name(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_GET_SPEC_PROPERTIES, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainSpecPropertiesRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainSpecPropertiesResponse = match host.get_spec_properties(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_BROADCAST_TRANSACTION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainTransactionBroadcastRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainTransactionBroadcastResponse = match host.broadcast_transaction(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::CHAIN_STOP_TRANSACTION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainTransactionStopRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainTransactionStopResponse = match host.stop_transaction(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::CHAIN_GET_CHAIN_INFO, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chain::RemoteChainInfoRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::chain::RemoteChainInfoResponse = match host.get_chain_info(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_chat

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Chat + Send + Sync + 'static, -{ - { - let execution_allowed = dispatcher.allows_execution(ProductExecutionKind::Worker); - let host = host.clone(); - dispatcher.on_request(wire_table::CHAT_CREATE_ROOM, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chat::HostChatCreateRoomRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - if !execution_allowed { - let error: truapi::CallError = - truapi::CallError::Denied; - return Ok(encode_versioned_err_payload(error, target_version)); - } - let response: versioned::chat::HostChatCreateRoomResponse = match host.create_room(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let execution_allowed = dispatcher.allows_execution(ProductExecutionKind::Worker); - let host = host.clone(); - dispatcher.on_request(wire_table::CHAT_REGISTER_BOT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chat::HostChatRegisterBotRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - if !execution_allowed { - let error: truapi::CallError = - truapi::CallError::Denied; - return Ok(encode_versioned_err_payload(error, target_version)); - } - let response: versioned::chat::HostChatRegisterBotResponse = match host.register_bot(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let execution_allowed = dispatcher.allows_execution(ProductExecutionKind::Worker); - let host = host.clone(); - dispatcher.on_subscription( - wire_table::CHAT_LIST_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let _ = bytes; - let cx = CallContext::with_request_id(request_id.clone()); - if !execution_allowed { - return Err(Vec::new()); - } - let stream = host.list_subscribe(&cx).await; - Ok(subscription_stream::< - versioned::chat::HostChatListSubscribeItem, - _, - >(stream)) - }) - }, - ); - } - { - let execution_allowed = dispatcher.allows_execution(ProductExecutionKind::Worker); - let host = host.clone(); - dispatcher.on_request(wire_table::CHAT_POST_MESSAGE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::chat::HostChatPostMessageRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - if !execution_allowed { - let error: truapi::CallError = - truapi::CallError::Denied; - return Ok(encode_versioned_err_payload(error, target_version)); - } - let response: versioned::chat::HostChatPostMessageResponse = match host.post_message(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let execution_allowed = dispatcher.allows_execution(ProductExecutionKind::Worker); - let host = host; - dispatcher.on_subscription( - wire_table::CHAT_ACTION_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let _ = bytes; - let cx = CallContext::with_request_id(request_id.clone()); - if !execution_allowed { - return Err(Vec::new()); - } - let stream = host.action_subscribe(&cx).await; - Ok(subscription_stream::< - versioned::chat::HostChatActionSubscribeItem, - _, - >(stream)) - }) - }, - ); - } -} - -fn register_coin_payment

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: CoinPayment + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::COIN_PAYMENT_CREATE_PURSE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentCreatePurseRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::coin_payment::HostCoinPaymentCreatePurseResponse = match host.create_purse(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::COIN_PAYMENT_QUERY_PURSE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentQueryPurseRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::coin_payment::HostCoinPaymentQueryPurseResponse = match host.query_purse(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::COIN_PAYMENT_REBALANCE_PURSE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentRebalancePurseRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.rebalance_purse(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::COIN_PAYMENT_DELETE_PURSE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentDeletePurseRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.delete_purse(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::COIN_PAYMENT_CREATE_RECEIVABLE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentCreateReceivableRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::coin_payment::HostCoinPaymentCreateReceivableResponse = match host.create_receivable(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::COIN_PAYMENT_CREATE_CHEQUE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentCreateChequeRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::coin_payment::HostCoinPaymentCreateChequeResponse = match host.create_cheque(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::COIN_PAYMENT_DEPOSIT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentDepositRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.deposit(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::COIN_PAYMENT_REFUND, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentRefundRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.refund(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host; - dispatcher.on_subscription(wire_table::COIN_PAYMENT_LISTEN_FOR_PAYMENT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::coin_payment::HostCoinPaymentListenForRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.listen_for_payment(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } -} - -fn register_entropy

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Entropy + Send + Sync + 'static, -{ - { - let host = host; - dispatcher.on_request(wire_table::ENTROPY_DERIVE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::entropy::HostDeriveEntropyRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::entropy::HostDeriveEntropyResponse = match host.derive(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_local_storage

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: LocalStorage + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::LOCAL_STORAGE_READ, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::local_storage::HostLocalStorageReadRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::local_storage::HostLocalStorageReadResponse = match host.read(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::LOCAL_STORAGE_WRITE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::local_storage::HostLocalStorageWriteRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::local_storage::HostLocalStorageWriteResponse = match host.write(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::LOCAL_STORAGE_CLEAR, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::local_storage::HostLocalStorageClearRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::local_storage::HostLocalStorageClearResponse = match host.clear(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_locale

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Locale + Send + Sync + 'static, -{ - { - let host = host; - dispatcher.on_subscription( - wire_table::LOCALE_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let _ = bytes; - let cx = CallContext::with_request_id(request_id.clone()); - let stream = host.subscribe(&cx).await; - Ok(subscription_stream::< - versioned::locale::HostLocaleSubscribeItem, - _, - >(stream)) - }) - }, - ); - } -} - -fn register_notifications

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Notifications + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::NOTIFICATIONS_SEND_PUSH_NOTIFICATION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::notifications::HostPushNotificationRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::notifications::HostPushNotificationResponse = match host.send_push_notification(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::NOTIFICATIONS_CANCEL_PUSH_NOTIFICATION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::notifications::HostPushNotificationCancelRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::notifications::HostPushNotificationCancelResponse = match host.cancel_push_notification(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_payment

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Payment + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::PAYMENT_BALANCE_SUBSCRIBE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::payment::HostPaymentBalanceSubscribeRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.balance_subscribe(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::PAYMENT_REQUEST, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::payment::HostPaymentRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::payment::HostPaymentResponse = match host.request(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::PAYMENT_STATUS_SUBSCRIBE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::payment::HostPaymentStatusSubscribeRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.status_subscribe(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::PAYMENT_TOP_UP, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::payment::HostPaymentTopUpRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::payment::HostPaymentTopUpResponse = match host.top_up(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_permissions

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Permissions + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::PERMISSIONS_REQUEST_DEVICE_PERMISSION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::permissions::HostDevicePermissionRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::permissions::HostDevicePermissionResponse = match host.request_device_permission(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::PERMISSIONS_REQUEST_REMOTE_PERMISSION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::permissions::RemotePermissionRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::permissions::RemotePermissionResponse = match host.request_remote_permission(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_preimage

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Preimage + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_subscription( - wire_table::PREIMAGE_LOOKUP_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::preimage::RemotePreimageLookupSubscribeRequest = - match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(_) => return Err(Vec::new()), - }; - let cx = CallContext::with_request_id(request_id.clone()); - let stream = host.lookup_subscribe(&cx, request).await; - Ok(subscription_stream::< - versioned::preimage::RemotePreimageLookupSubscribeItem, - _, - >(stream)) - }) - }, - ); - } - { - let host = host; - dispatcher.on_request(wire_table::PREIMAGE_SUBMIT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::preimage::RemotePreimageSubmitRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::preimage::RemotePreimageSubmitResponse = match host.submit(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_resource_allocation

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: ResourceAllocation + Send + Sync + 'static, -{ - { - let host = host; - dispatcher.on_request(wire_table::RESOURCE_ALLOCATION_REQUEST, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::resource_allocation::HostRequestResourceAllocationRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::resource_allocation::HostRequestResourceAllocationResponse = match host.request(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_signing

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Signing + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::SIGNING_CREATE_TRANSACTION, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostCreateTransactionRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostCreateTransactionResponse = match host.create_transaction(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SIGNING_CREATE_TRANSACTION_WITH_LEGACY_ACCOUNT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostCreateTransactionWithLegacyAccountRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostCreateTransactionWithLegacyAccountResponse = match host.create_transaction_with_legacy_account(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SIGNING_SIGN_RAW_WITH_LEGACY_ACCOUNT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostSignRawWithLegacyAccountRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostSignRawWithLegacyAccountResponse = match host.sign_raw_with_legacy_account(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SIGNING_SIGN_PAYLOAD_WITH_LEGACY_ACCOUNT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostSignPayloadWithLegacyAccountRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostSignPayloadWithLegacyAccountResponse = match host.sign_payload_with_legacy_account(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SIGNING_SIGN_RAW, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostSignRawRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostSignRawResponse = match host.sign_raw(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::SIGNING_SIGN_PAYLOAD, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::signing::HostSignPayloadRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::signing::HostSignPayloadResponse = match host.sign_payload(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_statement_store

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: StatementStore + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_subscription(wire_table::STATEMENT_STORE_SUBSCRIBE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::statement_store::RemoteStatementStoreSubscribeRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { - reason: err.to_string(), - }; - return Err(encode_versioned_interrupt_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let stream = match host.subscribe(&cx, request).await { - Ok(sub) => sub, - Err(err) => { - return Err(encode_versioned_interrupt_payload(err, target_version)); - } - }; - Ok(subscription_stream::(stream)) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::STATEMENT_STORE_CREATE_PROOF, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::statement_store::RemoteStatementStoreCreateProofRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::statement_store::RemoteStatementStoreCreateProofResponse = match host.create_proof(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::STATEMENT_STORE_CREATE_PROOF_AUTHORIZED, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::statement_store::RemoteStatementStoreCreateProofAuthorizedRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::statement_store::RemoteStatementStoreCreateProofAuthorizedResponse = match host.create_proof_authorized(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::STATEMENT_STORE_SUBMIT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::statement_store::RemoteStatementStoreSubmitRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - match host.submit(&cx, request).await { - Ok(()) => Ok(encode_versioned_unit_ok_payload(target_version)), - Err(err) => { - Ok(encode_versioned_err_payload(err, target_version)) - } - } - }) - }); - } -} - -fn register_system

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: System + Send + Sync + 'static, -{ - { - let host = host.clone(); - dispatcher.on_request(wire_table::SYSTEM_HANDSHAKE, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::system::HostHandshakeRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::system::HostHandshakeResponse = match host.handshake(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SYSTEM_FEATURE_SUPPORTED, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::system::HostFeatureSupportedRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::system::HostFeatureSupportedResponse = match host.feature_supported(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SYSTEM_NAVIGATE_TO, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::system::HostNavigateToRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::system::HostNavigateToResponse = match host.navigate_to(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host.clone(); - dispatcher.on_request(wire_table::SYSTEM_HOST_INFO, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::system::HostInfoRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::system::HostInfoResponse = match host.host_info(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } - { - let host = host; - dispatcher.on_request(wire_table::SYSTEM_GET_PRODUCT_CONTEXT, move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let request: versioned::system::HostGetProductContextRequest = match Decode::decode(&mut &bytes[..]) { - Ok(request) => request, - Err(err) => { - let error: truapi::CallError = - truapi::CallError::MalformedFrame { reason: err.to_string() }; - return Ok(encode_versioned_err_payload( - error, - ::LATEST, - )); - } - }; - let target_version = request.version(); - let cx = CallContext::with_request_id(request_id.clone()); - let response: versioned::system::HostGetProductContextResponse = match host.get_product_context(&cx, request).await { - Ok(value) => value, - Err(err) => { - return Ok(encode_versioned_err_payload( - downgrade_call_error(err, target_version), - target_version, - )); - } - }; - // Downgraded to the caller's version: a handler answers in - // latest terms, and a peer that asked in an older version - // cannot decode a newer variant. - Ok(encode_versioned_ok_payload( - ::from_latest( - truapi::versioned::IntoLatest::into_latest(response), - target_version, - ), - )) - }) - }); - } -} - -fn register_theme

(dispatcher: &mut Dispatcher, host: Arc

) -where - P: Theme + Send + Sync + 'static, -{ - { - let host = host; - dispatcher.on_subscription( - wire_table::THEME_SUBSCRIBE, - move |request_id: String, bytes: Vec| { - let host = host.clone(); - Box::pin(async move { - let _ = bytes; - let cx = CallContext::with_request_id(request_id.clone()); - let stream = host.subscribe(&cx).await; - Ok(subscription_stream::< - versioned::theme::HostThemeSubscribeItem, - _, - >(stream)) - }) - }, - ); - } -} diff --git a/rust/crates/truapi-server/src/generated/mod.rs b/rust/crates/truapi-server/src/generated/mod.rs deleted file mode 100644 index 770a015d0..000000000 --- a/rust/crates/truapi-server/src/generated/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Generated by truapi-codegen. Do not edit. - -pub mod dispatcher; -pub mod wire_table; diff --git a/rust/crates/truapi-server/src/generated/wire_table.rs b/rust/crates/truapi-server/src/generated/wire_table.rs deleted file mode 100644 index 3a3783b85..000000000 --- a/rust/crates/truapi-server/src/generated/wire_table.rs +++ /dev/null @@ -1,804 +0,0 @@ -//! Wire-protocol discriminant table. -//! -//! Auto-generated by truapi-codegen. Do not edit. -//! -//! Each method reserves either two ids (request/response) or four -//! (start/stop/interrupt/receive). The ids for each method are exposed -//! as a named const (`PREIMAGE_SUBMIT`, ...); [`WIRE_TABLE`] and the -//! generated dispatcher both reference those consts so the numbers live -//! in exactly one place. The table is sorted by request/start id. - -/// Request method wire discriminants. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct RequestFrameIds { - /// Discriminant for the request frame. - pub request_id: u8, - /// Discriminant for the response frame. - pub response_id: u8, -} - -/// Subscription method wire discriminants. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SubscriptionFrameIds { - /// Discriminant for the start frame. - pub start_id: u8, - /// Discriminant for the stop frame. - pub stop_id: u8, - /// Discriminant for the interrupt frame (server-initiated termination). - pub interrupt_id: u8, - /// Discriminant for each receive frame (a streamed item). - pub receive_id: u8, -} - -/// A single wire-table row. -pub struct WireEntry { - /// Method name from the Rust trait. - pub method: &'static str, - /// What kind of slot this entry describes. - pub kind: WireKind, -} - -/// Wire-slot shape: request/response pair or subscription quartet. -pub enum WireKind { - /// Request/response method. - Request(RequestFrameIds), - /// Subscription method. - Subscription(SubscriptionFrameIds), -} - -/// Wire discriminants for `system_handshake`. -pub const SYSTEM_HANDSHAKE: RequestFrameIds = RequestFrameIds { - request_id: 0, - response_id: 1, -}; - -/// Wire discriminants for `system_feature_supported`. -pub const SYSTEM_FEATURE_SUPPORTED: RequestFrameIds = RequestFrameIds { - request_id: 2, - response_id: 3, -}; - -/// Wire discriminants for `notifications_send_push_notification`. -pub const NOTIFICATIONS_SEND_PUSH_NOTIFICATION: RequestFrameIds = RequestFrameIds { - request_id: 4, - response_id: 5, -}; - -/// Wire discriminants for `system_navigate_to`. -pub const SYSTEM_NAVIGATE_TO: RequestFrameIds = RequestFrameIds { - request_id: 6, - response_id: 7, -}; - -/// Wire discriminants for `permissions_request_device_permission`. -pub const PERMISSIONS_REQUEST_DEVICE_PERMISSION: RequestFrameIds = RequestFrameIds { - request_id: 8, - response_id: 9, -}; - -/// Wire discriminants for `permissions_request_remote_permission`. -pub const PERMISSIONS_REQUEST_REMOTE_PERMISSION: RequestFrameIds = RequestFrameIds { - request_id: 10, - response_id: 11, -}; - -/// Wire discriminants for `local_storage_read`. -pub const LOCAL_STORAGE_READ: RequestFrameIds = RequestFrameIds { - request_id: 12, - response_id: 13, -}; - -/// Wire discriminants for `local_storage_write`. -pub const LOCAL_STORAGE_WRITE: RequestFrameIds = RequestFrameIds { - request_id: 14, - response_id: 15, -}; - -/// Wire discriminants for `local_storage_clear`. -pub const LOCAL_STORAGE_CLEAR: RequestFrameIds = RequestFrameIds { - request_id: 16, - response_id: 17, -}; - -/// Wire discriminants for `account_connection_status_subscribe`. -pub const ACCOUNT_CONNECTION_STATUS_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 18, - stop_id: 19, - interrupt_id: 20, - receive_id: 21, -}; - -/// Wire discriminants for `account_get_account`. -pub const ACCOUNT_GET_ACCOUNT: RequestFrameIds = RequestFrameIds { - request_id: 22, - response_id: 23, -}; - -/// Wire discriminants for `account_get_account_alias`. -pub const ACCOUNT_GET_ACCOUNT_ALIAS: RequestFrameIds = RequestFrameIds { - request_id: 24, - response_id: 25, -}; - -/// Wire discriminants for `account_create_account_proof`. -pub const ACCOUNT_CREATE_ACCOUNT_PROOF: RequestFrameIds = RequestFrameIds { - request_id: 26, - response_id: 27, -}; - -/// Wire discriminants for `account_get_legacy_accounts`. -pub const ACCOUNT_GET_LEGACY_ACCOUNTS: RequestFrameIds = RequestFrameIds { - request_id: 28, - response_id: 29, -}; - -/// Wire discriminants for `signing_create_transaction`. -pub const SIGNING_CREATE_TRANSACTION: RequestFrameIds = RequestFrameIds { - request_id: 30, - response_id: 31, -}; - -/// Wire discriminants for `signing_create_transaction_with_legacy_account`. -pub const SIGNING_CREATE_TRANSACTION_WITH_LEGACY_ACCOUNT: RequestFrameIds = RequestFrameIds { - request_id: 32, - response_id: 33, -}; - -/// Wire discriminants for `signing_sign_raw_with_legacy_account`. -pub const SIGNING_SIGN_RAW_WITH_LEGACY_ACCOUNT: RequestFrameIds = RequestFrameIds { - request_id: 34, - response_id: 35, -}; - -/// Wire discriminants for `signing_sign_payload_with_legacy_account`. -pub const SIGNING_SIGN_PAYLOAD_WITH_LEGACY_ACCOUNT: RequestFrameIds = RequestFrameIds { - request_id: 36, - response_id: 37, -}; - -/// Wire discriminants for `chat_create_room`. -pub const CHAT_CREATE_ROOM: RequestFrameIds = RequestFrameIds { - request_id: 38, - response_id: 39, -}; - -/// Wire discriminants for `chat_register_bot`. -pub const CHAT_REGISTER_BOT: RequestFrameIds = RequestFrameIds { - request_id: 40, - response_id: 41, -}; - -/// Wire discriminants for `chat_list_subscribe`. -pub const CHAT_LIST_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 42, - stop_id: 43, - interrupt_id: 44, - receive_id: 45, -}; - -/// Wire discriminants for `chat_post_message`. -pub const CHAT_POST_MESSAGE: RequestFrameIds = RequestFrameIds { - request_id: 46, - response_id: 47, -}; - -/// Wire discriminants for `chat_action_subscribe`. -pub const CHAT_ACTION_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 48, - stop_id: 49, - interrupt_id: 50, - receive_id: 51, -}; - -/// Wire discriminants for `chat_custom_message_render`. -pub const CHAT_CUSTOM_MESSAGE_RENDER: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 52, - stop_id: 53, - interrupt_id: 54, - receive_id: 55, -}; - -/// Wire discriminants for `statement_store_subscribe`. -pub const STATEMENT_STORE_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 56, - stop_id: 57, - interrupt_id: 58, - receive_id: 59, -}; - -/// Wire discriminants for `statement_store_create_proof`. -pub const STATEMENT_STORE_CREATE_PROOF: RequestFrameIds = RequestFrameIds { - request_id: 60, - response_id: 61, -}; - -/// Wire discriminants for `statement_store_submit`. -pub const STATEMENT_STORE_SUBMIT: RequestFrameIds = RequestFrameIds { - request_id: 62, - response_id: 63, -}; - -/// Wire discriminants for `preimage_lookup_subscribe`. -pub const PREIMAGE_LOOKUP_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 64, - stop_id: 65, - interrupt_id: 66, - receive_id: 67, -}; - -/// Wire discriminants for `preimage_submit`. -pub const PREIMAGE_SUBMIT: RequestFrameIds = RequestFrameIds { - request_id: 68, - response_id: 69, -}; - -/// Wire discriminants for `chain_follow_head_subscribe`. -pub const CHAIN_FOLLOW_HEAD_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 76, - stop_id: 77, - interrupt_id: 78, - receive_id: 79, -}; - -/// Wire discriminants for `chain_get_head_header`. -pub const CHAIN_GET_HEAD_HEADER: RequestFrameIds = RequestFrameIds { - request_id: 80, - response_id: 81, -}; - -/// Wire discriminants for `chain_get_head_body`. -pub const CHAIN_GET_HEAD_BODY: RequestFrameIds = RequestFrameIds { - request_id: 82, - response_id: 83, -}; - -/// Wire discriminants for `chain_get_head_storage`. -pub const CHAIN_GET_HEAD_STORAGE: RequestFrameIds = RequestFrameIds { - request_id: 84, - response_id: 85, -}; - -/// Wire discriminants for `chain_call_head`. -pub const CHAIN_CALL_HEAD: RequestFrameIds = RequestFrameIds { - request_id: 86, - response_id: 87, -}; - -/// Wire discriminants for `chain_unpin_head`. -pub const CHAIN_UNPIN_HEAD: RequestFrameIds = RequestFrameIds { - request_id: 88, - response_id: 89, -}; - -/// Wire discriminants for `chain_continue_head`. -pub const CHAIN_CONTINUE_HEAD: RequestFrameIds = RequestFrameIds { - request_id: 90, - response_id: 91, -}; - -/// Wire discriminants for `chain_stop_head_operation`. -pub const CHAIN_STOP_HEAD_OPERATION: RequestFrameIds = RequestFrameIds { - request_id: 92, - response_id: 93, -}; - -/// Wire discriminants for `chain_get_spec_genesis_hash`. -pub const CHAIN_GET_SPEC_GENESIS_HASH: RequestFrameIds = RequestFrameIds { - request_id: 94, - response_id: 95, -}; - -/// Wire discriminants for `chain_get_spec_chain_name`. -pub const CHAIN_GET_SPEC_CHAIN_NAME: RequestFrameIds = RequestFrameIds { - request_id: 96, - response_id: 97, -}; - -/// Wire discriminants for `chain_get_spec_properties`. -pub const CHAIN_GET_SPEC_PROPERTIES: RequestFrameIds = RequestFrameIds { - request_id: 98, - response_id: 99, -}; - -/// Wire discriminants for `chain_broadcast_transaction`. -pub const CHAIN_BROADCAST_TRANSACTION: RequestFrameIds = RequestFrameIds { - request_id: 100, - response_id: 101, -}; - -/// Wire discriminants for `chain_stop_transaction`. -pub const CHAIN_STOP_TRANSACTION: RequestFrameIds = RequestFrameIds { - request_id: 102, - response_id: 103, -}; - -/// Wire discriminants for `theme_subscribe`. -pub const THEME_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 104, - stop_id: 105, - interrupt_id: 106, - receive_id: 107, -}; - -/// Wire discriminants for `entropy_derive`. -pub const ENTROPY_DERIVE: RequestFrameIds = RequestFrameIds { - request_id: 108, - response_id: 109, -}; - -/// Wire discriminants for `account_get_user_id`. -pub const ACCOUNT_GET_USER_ID: RequestFrameIds = RequestFrameIds { - request_id: 110, - response_id: 111, -}; - -/// Wire discriminants for `account_request_login`. -pub const ACCOUNT_REQUEST_LOGIN: RequestFrameIds = RequestFrameIds { - request_id: 112, - response_id: 113, -}; - -/// Wire discriminants for `signing_sign_raw`. -pub const SIGNING_SIGN_RAW: RequestFrameIds = RequestFrameIds { - request_id: 114, - response_id: 115, -}; - -/// Wire discriminants for `signing_sign_payload`. -pub const SIGNING_SIGN_PAYLOAD: RequestFrameIds = RequestFrameIds { - request_id: 116, - response_id: 117, -}; - -/// Wire discriminants for `payment_balance_subscribe`. -pub const PAYMENT_BALANCE_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 118, - stop_id: 119, - interrupt_id: 120, - receive_id: 121, -}; - -/// Wire discriminants for `payment_top_up`. -pub const PAYMENT_TOP_UP: RequestFrameIds = RequestFrameIds { - request_id: 122, - response_id: 123, -}; - -/// Wire discriminants for `payment_request`. -pub const PAYMENT_REQUEST: RequestFrameIds = RequestFrameIds { - request_id: 124, - response_id: 125, -}; - -/// Wire discriminants for `payment_status_subscribe`. -pub const PAYMENT_STATUS_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 126, - stop_id: 127, - interrupt_id: 128, - receive_id: 129, -}; - -/// Wire discriminants for `resource_allocation_request`. -pub const RESOURCE_ALLOCATION_REQUEST: RequestFrameIds = RequestFrameIds { - request_id: 130, - response_id: 131, -}; - -/// Wire discriminants for `statement_store_create_proof_authorized`. -pub const STATEMENT_STORE_CREATE_PROOF_AUTHORIZED: RequestFrameIds = RequestFrameIds { - request_id: 132, - response_id: 133, -}; - -/// Wire discriminants for `notifications_cancel_push_notification`. -pub const NOTIFICATIONS_CANCEL_PUSH_NOTIFICATION: RequestFrameIds = RequestFrameIds { - request_id: 134, - response_id: 135, -}; - -/// Wire discriminants for `coin_payment_create_purse`. -pub const COIN_PAYMENT_CREATE_PURSE: RequestFrameIds = RequestFrameIds { - request_id: 136, - response_id: 137, -}; - -/// Wire discriminants for `coin_payment_query_purse`. -pub const COIN_PAYMENT_QUERY_PURSE: RequestFrameIds = RequestFrameIds { - request_id: 138, - response_id: 139, -}; - -/// Wire discriminants for `coin_payment_rebalance_purse`. -pub const COIN_PAYMENT_REBALANCE_PURSE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 140, - stop_id: 141, - interrupt_id: 142, - receive_id: 143, -}; - -/// Wire discriminants for `coin_payment_delete_purse`. -pub const COIN_PAYMENT_DELETE_PURSE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 144, - stop_id: 145, - interrupt_id: 146, - receive_id: 147, -}; - -/// Wire discriminants for `coin_payment_create_receivable`. -pub const COIN_PAYMENT_CREATE_RECEIVABLE: RequestFrameIds = RequestFrameIds { - request_id: 148, - response_id: 149, -}; - -/// Wire discriminants for `coin_payment_create_cheque`. -pub const COIN_PAYMENT_CREATE_CHEQUE: RequestFrameIds = RequestFrameIds { - request_id: 150, - response_id: 151, -}; - -/// Wire discriminants for `coin_payment_deposit`. -pub const COIN_PAYMENT_DEPOSIT: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 152, - stop_id: 153, - interrupt_id: 154, - receive_id: 155, -}; - -/// Wire discriminants for `coin_payment_refund`. -pub const COIN_PAYMENT_REFUND: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 156, - stop_id: 157, - interrupt_id: 158, - receive_id: 159, -}; - -/// Wire discriminants for `coin_payment_listen_for_payment`. -pub const COIN_PAYMENT_LISTEN_FOR_PAYMENT: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 160, - stop_id: 161, - interrupt_id: 162, - receive_id: 163, -}; - -/// Wire discriminants for `account_sign_vrf`. -pub const ACCOUNT_SIGN_VRF: RequestFrameIds = RequestFrameIds { - request_id: 164, - response_id: 165, -}; - -/// Wire discriminants for `chain_get_chain_info`. -pub const CHAIN_GET_CHAIN_INFO: RequestFrameIds = RequestFrameIds { - request_id: 166, - response_id: 167, -}; - -/// Wire discriminants for `account_register_ring_vrf_key`. -pub const ACCOUNT_REGISTER_RING_VRF_KEY: RequestFrameIds = RequestFrameIds { - request_id: 168, - response_id: 169, -}; - -/// Wire discriminants for `account_list_ring_vrf_keys`. -pub const ACCOUNT_LIST_RING_VRF_KEYS: RequestFrameIds = RequestFrameIds { - request_id: 170, - response_id: 171, -}; - -/// Wire discriminants for `account_ring_vrf_sign`. -pub const ACCOUNT_RING_VRF_SIGN: RequestFrameIds = RequestFrameIds { - request_id: 172, - response_id: 173, -}; - -/// Wire discriminants for `system_get_product_context`. -pub const SYSTEM_GET_PRODUCT_CONTEXT: RequestFrameIds = RequestFrameIds { - request_id: 190, - response_id: 191, -}; - -/// Wire discriminants for `system_host_info`. -pub const SYSTEM_HOST_INFO: RequestFrameIds = RequestFrameIds { - request_id: 192, - response_id: 193, -}; - -/// Wire discriminants for `locale_subscribe`. -pub const LOCALE_SUBSCRIBE: SubscriptionFrameIds = SubscriptionFrameIds { - start_id: 194, - stop_id: 195, - interrupt_id: 196, - receive_id: 197, -}; - -/// The full wire table. Ordering is part of the wire protocol; -/// only ever append. Removed methods leave their slot empty. -pub const WIRE_TABLE: &[WireEntry] = &[ - WireEntry { - method: "system_handshake", - kind: WireKind::Request(SYSTEM_HANDSHAKE), - }, - WireEntry { - method: "system_feature_supported", - kind: WireKind::Request(SYSTEM_FEATURE_SUPPORTED), - }, - WireEntry { - method: "notifications_send_push_notification", - kind: WireKind::Request(NOTIFICATIONS_SEND_PUSH_NOTIFICATION), - }, - WireEntry { - method: "system_navigate_to", - kind: WireKind::Request(SYSTEM_NAVIGATE_TO), - }, - WireEntry { - method: "permissions_request_device_permission", - kind: WireKind::Request(PERMISSIONS_REQUEST_DEVICE_PERMISSION), - }, - WireEntry { - method: "permissions_request_remote_permission", - kind: WireKind::Request(PERMISSIONS_REQUEST_REMOTE_PERMISSION), - }, - WireEntry { - method: "local_storage_read", - kind: WireKind::Request(LOCAL_STORAGE_READ), - }, - WireEntry { - method: "local_storage_write", - kind: WireKind::Request(LOCAL_STORAGE_WRITE), - }, - WireEntry { - method: "local_storage_clear", - kind: WireKind::Request(LOCAL_STORAGE_CLEAR), - }, - WireEntry { - method: "account_connection_status_subscribe", - kind: WireKind::Subscription(ACCOUNT_CONNECTION_STATUS_SUBSCRIBE), - }, - WireEntry { - method: "account_get_account", - kind: WireKind::Request(ACCOUNT_GET_ACCOUNT), - }, - WireEntry { - method: "account_get_account_alias", - kind: WireKind::Request(ACCOUNT_GET_ACCOUNT_ALIAS), - }, - WireEntry { - method: "account_create_account_proof", - kind: WireKind::Request(ACCOUNT_CREATE_ACCOUNT_PROOF), - }, - WireEntry { - method: "account_get_legacy_accounts", - kind: WireKind::Request(ACCOUNT_GET_LEGACY_ACCOUNTS), - }, - WireEntry { - method: "signing_create_transaction", - kind: WireKind::Request(SIGNING_CREATE_TRANSACTION), - }, - WireEntry { - method: "signing_create_transaction_with_legacy_account", - kind: WireKind::Request(SIGNING_CREATE_TRANSACTION_WITH_LEGACY_ACCOUNT), - }, - WireEntry { - method: "signing_sign_raw_with_legacy_account", - kind: WireKind::Request(SIGNING_SIGN_RAW_WITH_LEGACY_ACCOUNT), - }, - WireEntry { - method: "signing_sign_payload_with_legacy_account", - kind: WireKind::Request(SIGNING_SIGN_PAYLOAD_WITH_LEGACY_ACCOUNT), - }, - WireEntry { - method: "chat_create_room", - kind: WireKind::Request(CHAT_CREATE_ROOM), - }, - WireEntry { - method: "chat_register_bot", - kind: WireKind::Request(CHAT_REGISTER_BOT), - }, - WireEntry { - method: "chat_list_subscribe", - kind: WireKind::Subscription(CHAT_LIST_SUBSCRIBE), - }, - WireEntry { - method: "chat_post_message", - kind: WireKind::Request(CHAT_POST_MESSAGE), - }, - WireEntry { - method: "chat_action_subscribe", - kind: WireKind::Subscription(CHAT_ACTION_SUBSCRIBE), - }, - WireEntry { - method: "chat_custom_message_render", - kind: WireKind::Subscription(CHAT_CUSTOM_MESSAGE_RENDER), - }, - WireEntry { - method: "statement_store_subscribe", - kind: WireKind::Subscription(STATEMENT_STORE_SUBSCRIBE), - }, - WireEntry { - method: "statement_store_create_proof", - kind: WireKind::Request(STATEMENT_STORE_CREATE_PROOF), - }, - WireEntry { - method: "statement_store_submit", - kind: WireKind::Request(STATEMENT_STORE_SUBMIT), - }, - WireEntry { - method: "preimage_lookup_subscribe", - kind: WireKind::Subscription(PREIMAGE_LOOKUP_SUBSCRIBE), - }, - WireEntry { - method: "preimage_submit", - kind: WireKind::Request(PREIMAGE_SUBMIT), - }, - WireEntry { - method: "chain_follow_head_subscribe", - kind: WireKind::Subscription(CHAIN_FOLLOW_HEAD_SUBSCRIBE), - }, - WireEntry { - method: "chain_get_head_header", - kind: WireKind::Request(CHAIN_GET_HEAD_HEADER), - }, - WireEntry { - method: "chain_get_head_body", - kind: WireKind::Request(CHAIN_GET_HEAD_BODY), - }, - WireEntry { - method: "chain_get_head_storage", - kind: WireKind::Request(CHAIN_GET_HEAD_STORAGE), - }, - WireEntry { - method: "chain_call_head", - kind: WireKind::Request(CHAIN_CALL_HEAD), - }, - WireEntry { - method: "chain_unpin_head", - kind: WireKind::Request(CHAIN_UNPIN_HEAD), - }, - WireEntry { - method: "chain_continue_head", - kind: WireKind::Request(CHAIN_CONTINUE_HEAD), - }, - WireEntry { - method: "chain_stop_head_operation", - kind: WireKind::Request(CHAIN_STOP_HEAD_OPERATION), - }, - WireEntry { - method: "chain_get_spec_genesis_hash", - kind: WireKind::Request(CHAIN_GET_SPEC_GENESIS_HASH), - }, - WireEntry { - method: "chain_get_spec_chain_name", - kind: WireKind::Request(CHAIN_GET_SPEC_CHAIN_NAME), - }, - WireEntry { - method: "chain_get_spec_properties", - kind: WireKind::Request(CHAIN_GET_SPEC_PROPERTIES), - }, - WireEntry { - method: "chain_broadcast_transaction", - kind: WireKind::Request(CHAIN_BROADCAST_TRANSACTION), - }, - WireEntry { - method: "chain_stop_transaction", - kind: WireKind::Request(CHAIN_STOP_TRANSACTION), - }, - WireEntry { - method: "theme_subscribe", - kind: WireKind::Subscription(THEME_SUBSCRIBE), - }, - WireEntry { - method: "entropy_derive", - kind: WireKind::Request(ENTROPY_DERIVE), - }, - WireEntry { - method: "account_get_user_id", - kind: WireKind::Request(ACCOUNT_GET_USER_ID), - }, - WireEntry { - method: "account_request_login", - kind: WireKind::Request(ACCOUNT_REQUEST_LOGIN), - }, - WireEntry { - method: "signing_sign_raw", - kind: WireKind::Request(SIGNING_SIGN_RAW), - }, - WireEntry { - method: "signing_sign_payload", - kind: WireKind::Request(SIGNING_SIGN_PAYLOAD), - }, - WireEntry { - method: "payment_balance_subscribe", - kind: WireKind::Subscription(PAYMENT_BALANCE_SUBSCRIBE), - }, - WireEntry { - method: "payment_top_up", - kind: WireKind::Request(PAYMENT_TOP_UP), - }, - WireEntry { - method: "payment_request", - kind: WireKind::Request(PAYMENT_REQUEST), - }, - WireEntry { - method: "payment_status_subscribe", - kind: WireKind::Subscription(PAYMENT_STATUS_SUBSCRIBE), - }, - WireEntry { - method: "resource_allocation_request", - kind: WireKind::Request(RESOURCE_ALLOCATION_REQUEST), - }, - WireEntry { - method: "statement_store_create_proof_authorized", - kind: WireKind::Request(STATEMENT_STORE_CREATE_PROOF_AUTHORIZED), - }, - WireEntry { - method: "notifications_cancel_push_notification", - kind: WireKind::Request(NOTIFICATIONS_CANCEL_PUSH_NOTIFICATION), - }, - WireEntry { - method: "coin_payment_create_purse", - kind: WireKind::Request(COIN_PAYMENT_CREATE_PURSE), - }, - WireEntry { - method: "coin_payment_query_purse", - kind: WireKind::Request(COIN_PAYMENT_QUERY_PURSE), - }, - WireEntry { - method: "coin_payment_rebalance_purse", - kind: WireKind::Subscription(COIN_PAYMENT_REBALANCE_PURSE), - }, - WireEntry { - method: "coin_payment_delete_purse", - kind: WireKind::Subscription(COIN_PAYMENT_DELETE_PURSE), - }, - WireEntry { - method: "coin_payment_create_receivable", - kind: WireKind::Request(COIN_PAYMENT_CREATE_RECEIVABLE), - }, - WireEntry { - method: "coin_payment_create_cheque", - kind: WireKind::Request(COIN_PAYMENT_CREATE_CHEQUE), - }, - WireEntry { - method: "coin_payment_deposit", - kind: WireKind::Subscription(COIN_PAYMENT_DEPOSIT), - }, - WireEntry { - method: "coin_payment_refund", - kind: WireKind::Subscription(COIN_PAYMENT_REFUND), - }, - WireEntry { - method: "coin_payment_listen_for_payment", - kind: WireKind::Subscription(COIN_PAYMENT_LISTEN_FOR_PAYMENT), - }, - WireEntry { - method: "account_sign_vrf", - kind: WireKind::Request(ACCOUNT_SIGN_VRF), - }, - WireEntry { - method: "chain_get_chain_info", - kind: WireKind::Request(CHAIN_GET_CHAIN_INFO), - }, - WireEntry { - method: "account_register_ring_vrf_key", - kind: WireKind::Request(ACCOUNT_REGISTER_RING_VRF_KEY), - }, - WireEntry { - method: "account_list_ring_vrf_keys", - kind: WireKind::Request(ACCOUNT_LIST_RING_VRF_KEYS), - }, - WireEntry { - method: "account_ring_vrf_sign", - kind: WireKind::Request(ACCOUNT_RING_VRF_SIGN), - }, - WireEntry { - method: "system_get_product_context", - kind: WireKind::Request(SYSTEM_GET_PRODUCT_CONTEXT), - }, - WireEntry { - method: "system_host_info", - kind: WireKind::Request(SYSTEM_HOST_INFO), - }, - WireEntry { - method: "locale_subscribe", - kind: WireKind::Subscription(LOCALE_SUBSCRIBE), - }, -]; diff --git a/rust/crates/truapi-server/src/wasm/generated_bridge.rs b/rust/crates/truapi-server/src/wasm/generated_bridge.rs deleted file mode 100644 index d1b23cd61..000000000 --- a/rust/crates/truapi-server/src/wasm/generated_bridge.rs +++ /dev/null @@ -1,470 +0,0 @@ -//! Auto-generated by truapi-codegen. Do not edit. -//! -//! Mechanical wasm-bindgen callback bridge derived from -//! `truapi-platform`. Raw callback names and payload shapes match the -//! generated TypeScript host-callback adapter. - -use futures::stream::BoxStream; -use js_sys::{Function, Uint8Array}; -use parity_scale_codec::Encode; -use truapi::v01; -use wasm_bindgen::JsValue; - -use super::{ - WasmPlatform, call_js_function, decode_bytes, decode_js_item, generic, get_function, - get_optional_function, invoke_bool, invoke_bytes_return, invoke_js_subscription, - invoke_optional_bytes_return, invoke_unit, missing_callback, parse_optional_bytes_item, -}; - -/// JS-side callbacks invoked by the wasm platform bridge. Methods with -/// Rust default bodies are still required here because the generated TS -/// adapter resolves optional host callbacks before constructing this -/// raw callback object. -/// -/// Callbacks of an optional capability trait are replaced by a throwing -/// stub when the host omits the group. The core never reaches them: it -/// only holds an adapter for a capability whose `has_*` accessor is -/// true, and answers the rest with `Unsupported`. -pub(super) struct JsBridge { - pub(super) auth_state_changed: Function, - pub(super) chain_connect: Function, - pub(super) create_chat_room: Function, - pub(super) register_chat_bot: Function, - pub(super) post_chat_message: Function, - pub(super) subscribe_chat_rooms: Function, - pub(super) read_core_storage: Function, - pub(super) write_core_storage: Function, - pub(super) clear_core_storage: Function, - pub(super) feature_supported: Function, - pub(super) supported_chains: Function, - pub(super) subscribe_locale: Function, - pub(super) navigate_to: Function, - pub(super) push_notification: Function, - pub(super) cancel_notification: Function, - pub(super) device_permission_status: Function, - pub(super) device_permission: Function, - pub(super) remote_permission: Function, - pub(super) lookup_preimage: Function, - pub(super) read: Function, - pub(super) write: Function, - pub(super) clear: Function, - pub(super) subscribe_theme: Function, - pub(super) confirm_user_action: Function, - pub(super) chat_present: bool, - pub(super) permission_status_present: bool, -} - -impl JsBridge { - pub(super) fn from_js(callbacks: &JsValue) -> Result { - Ok(Self { - auth_state_changed: get_function(callbacks, "authStateChanged")?, - chain_connect: get_function(callbacks, "chainConnect")?, - create_chat_room: get_optional_function(callbacks, "createChatRoom")? - .unwrap_or_else(|| missing_callback("createChatRoom")), - register_chat_bot: get_optional_function(callbacks, "registerChatBot")? - .unwrap_or_else(|| missing_callback("registerChatBot")), - post_chat_message: get_optional_function(callbacks, "postChatMessage")? - .unwrap_or_else(|| missing_callback("postChatMessage")), - subscribe_chat_rooms: get_optional_function(callbacks, "subscribeChatRooms")? - .unwrap_or_else(|| missing_callback("subscribeChatRooms")), - read_core_storage: get_function(callbacks, "readCoreStorage")?, - write_core_storage: get_function(callbacks, "writeCoreStorage")?, - clear_core_storage: get_function(callbacks, "clearCoreStorage")?, - feature_supported: get_function(callbacks, "featureSupported")?, - supported_chains: get_function(callbacks, "supportedChains")?, - subscribe_locale: get_function(callbacks, "subscribeLocale")?, - navigate_to: get_function(callbacks, "navigateTo")?, - push_notification: get_function(callbacks, "pushNotification")?, - cancel_notification: get_function(callbacks, "cancelNotification")?, - device_permission_status: get_optional_function(callbacks, "devicePermissionStatus")? - .unwrap_or_else(|| missing_callback("devicePermissionStatus")), - device_permission: get_function(callbacks, "devicePermission")?, - remote_permission: get_function(callbacks, "remotePermission")?, - lookup_preimage: get_function(callbacks, "lookupPreimage")?, - read: get_function(callbacks, "read")?, - write: get_function(callbacks, "write")?, - clear: get_function(callbacks, "clear")?, - subscribe_theme: get_function(callbacks, "subscribeTheme")?, - confirm_user_action: get_function(callbacks, "confirmUserAction")?, - chat_present: get_optional_function(callbacks, "createChatRoom")?.is_some() - && get_optional_function(callbacks, "registerChatBot")?.is_some() - && get_optional_function(callbacks, "postChatMessage")?.is_some() - && get_optional_function(callbacks, "subscribeChatRooms")?.is_some(), - permission_status_present: get_optional_function(callbacks, "devicePermissionStatus")? - .is_some(), - }) - } - - /// Whether the host supplied every `chat` callback. - pub(super) fn has_chat(&self) -> bool { - self.chat_present - } - - /// Whether the host supplied every `permission_status` callback. - pub(super) fn has_permission_status(&self) -> bool { - self.permission_status_present - } -} - -impl truapi_platform::AuthPresenter for WasmPlatform { - fn auth_state_changed(&self, state: truapi_platform::AuthState) { - if let Err(reason) = call_js_function( - &self.bridge.auth_state_changed, - &vec![Uint8Array::from(state.encode().as_slice()).into()], - ) { - web_sys::console::error_1(&JsValue::from_str(&reason)); - } - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::ChatPlatform for WasmPlatform { - async fn create_chat_room( - &self, - product: &truapi_platform::ProductContext, - request: v01::HostChatCreateRoomRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.create_chat_room, - vec![ - Uint8Array::from(product.encode().as_slice()).into(), - Uint8Array::from(request.encode().as_slice()).into(), - ], - ) - .await - .map_err(|reason| v01::HostChatCreateRoomError::Unknown { reason })?; - decode_bytes::( - bytes, - "createChatRoom response did not decode", - ) - .map_err(|reason| v01::HostChatCreateRoomError::Unknown { reason }) - } - - async fn register_chat_bot( - &self, - product: &truapi_platform::ProductContext, - request: v01::HostChatRegisterBotRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.register_chat_bot, - vec![ - Uint8Array::from(product.encode().as_slice()).into(), - Uint8Array::from(request.encode().as_slice()).into(), - ], - ) - .await - .map_err(|reason| v01::HostChatRegisterBotError::Unknown { reason })?; - decode_bytes::( - bytes, - "registerChatBot response did not decode", - ) - .map_err(|reason| v01::HostChatRegisterBotError::Unknown { reason }) - } - - async fn post_chat_message( - &self, - product: &truapi_platform::ProductContext, - request: v01::HostChatPostMessageRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.post_chat_message, - vec![ - Uint8Array::from(product.encode().as_slice()).into(), - Uint8Array::from(request.encode().as_slice()).into(), - ], - ) - .await - .map_err(|reason| v01::HostChatPostMessageError::Unknown { reason })?; - decode_bytes::( - bytes, - "postChatMessage response did not decode", - ) - .map_err(|reason| v01::HostChatPostMessageError::Unknown { reason }) - } - - fn subscribe_chat_rooms( - &self, - product: &truapi_platform::ProductContext, - ) -> BoxStream<'static, Result> { - invoke_js_subscription( - &self.bridge.subscribe_chat_rooms, - Some(product.encode()), - parse_host_chat_list_subscribe_item_item, - ) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::CoreStorage for WasmPlatform { - async fn read_core_storage( - &self, - key: truapi_platform::CoreStorageKey, - ) -> Result>, v01::GenericError> { - invoke_optional_bytes_return( - &self.bridge.read_core_storage, - vec![Uint8Array::from(key.encode().as_slice()).into()], - "readCoreStorage must resolve to Uint8Array, null or undefined", - ) - .await - .map_err(generic) - } - - async fn write_core_storage( - &self, - key: truapi_platform::CoreStorageKey, - value: Vec, - ) -> Result<(), v01::GenericError> { - invoke_unit( - &self.bridge.write_core_storage, - vec![ - Uint8Array::from(key.encode().as_slice()).into(), - Uint8Array::from(value.as_slice()).into(), - ], - ) - .await - .map_err(generic) - } - - async fn clear_core_storage( - &self, - key: truapi_platform::CoreStorageKey, - ) -> Result<(), v01::GenericError> { - invoke_unit( - &self.bridge.clear_core_storage, - vec![Uint8Array::from(key.encode().as_slice()).into()], - ) - .await - .map_err(generic) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::Features for WasmPlatform { - async fn feature_supported( - &self, - request: v01::HostFeatureSupportedRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.feature_supported, - vec![Uint8Array::from(request.encode().as_slice()).into()], - ) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "featureSupported response did not decode", - ) - .map_err(generic) - } - - async fn supported_chains(&self) -> Result { - let bytes = invoke_bytes_return(&self.bridge.supported_chains, Vec::new()) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "supportedChains response did not decode", - ) - .map_err(generic) - } -} - -impl truapi_platform::LocaleHost for WasmPlatform { - fn subscribe_locale( - &self, - ) -> BoxStream<'static, Result> { - invoke_js_subscription( - &self.bridge.subscribe_locale, - None, - parse_host_locale_subscribe_item_item, - ) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::Navigation for WasmPlatform { - async fn navigate_to(&self, url: String) -> Result<(), v01::HostNavigateToError> { - invoke_unit(&self.bridge.navigate_to, vec![JsValue::from_str(&url)]) - .await - .map_err(|reason| v01::HostNavigateToError::Unknown { reason }) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::Notifications for WasmPlatform { - async fn push_notification( - &self, - notification: v01::HostPushNotificationRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.push_notification, - vec![Uint8Array::from(notification.encode().as_slice()).into()], - ) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "pushNotification response did not decode", - ) - .map_err(generic) - } - - async fn cancel_notification(&self, id: v01::NotificationId) -> Result<(), v01::GenericError> { - invoke_unit( - &self.bridge.cancel_notification, - vec![JsValue::from_f64(f64::from(id))], - ) - .await - .map_err(generic) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::PermissionStatusHost for WasmPlatform { - async fn device_permission_status( - &self, - request: v01::HostDevicePermissionRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.device_permission_status, - vec![Uint8Array::from(request.encode().as_slice()).into()], - ) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "devicePermissionStatus response did not decode", - ) - .map_err(generic) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::Permissions for WasmPlatform { - async fn device_permission( - &self, - request: v01::HostDevicePermissionRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.device_permission, - vec![Uint8Array::from(request.encode().as_slice()).into()], - ) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "devicePermission response did not decode", - ) - .map_err(generic) - } - - async fn remote_permission( - &self, - request: v01::RemotePermissionRequest, - ) -> Result { - let bytes = invoke_bytes_return( - &self.bridge.remote_permission, - vec![Uint8Array::from(request.encode().as_slice()).into()], - ) - .await - .map_err(generic)?; - decode_bytes::( - bytes, - "remotePermission response did not decode", - ) - .map_err(generic) - } -} - -impl truapi_platform::PreimageHost for WasmPlatform { - fn lookup_preimage( - &self, - key: Vec, - ) -> BoxStream<'static, Result>, v01::GenericError>> { - invoke_js_subscription( - &self.bridge.lookup_preimage, - Some(key), - parse_optional_bytes_item, - ) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::ProductStorage for WasmPlatform { - async fn read(&self, key: String) -> Result>, v01::HostLocalStorageReadError> { - invoke_optional_bytes_return( - &self.bridge.read, - vec![JsValue::from_str(&key)], - "read must resolve to Uint8Array, null or undefined", - ) - .await - .map_err(|reason| v01::HostLocalStorageReadError::Unknown { reason }) - } - - async fn write( - &self, - key: String, - value: Vec, - ) -> Result<(), v01::HostLocalStorageReadError> { - invoke_unit( - &self.bridge.write, - vec![ - JsValue::from_str(&key), - Uint8Array::from(value.as_slice()).into(), - ], - ) - .await - .map_err(|reason| v01::HostLocalStorageReadError::Unknown { reason }) - } - - async fn clear(&self, key: String) -> Result<(), v01::HostLocalStorageReadError> { - invoke_unit(&self.bridge.clear, vec![JsValue::from_str(&key)]) - .await - .map_err(|reason| v01::HostLocalStorageReadError::Unknown { reason }) - } -} - -impl truapi_platform::ThemeHost for WasmPlatform { - fn subscribe_theme( - &self, - ) -> BoxStream<'static, Result> { - invoke_js_subscription( - &self.bridge.subscribe_theme, - None, - parse_host_theme_subscribe_item_item, - ) - } -} - -#[truapi_platform::async_trait] -impl truapi_platform::UserConfirmation for WasmPlatform { - async fn confirm_user_action( - &self, - review: truapi_platform::UserConfirmationReview, - ) -> Result { - invoke_bool( - &self.bridge.confirm_user_action, - vec![Uint8Array::from(review.encode().as_slice()).into()], - ) - .await - .map_err(generic) - } -} - -fn parse_host_chat_list_subscribe_item_item( - value: JsValue, -) -> Result { - decode_js_item::(value, "HostChatListSubscribeItem") -} - -fn parse_host_locale_subscribe_item_item( - value: JsValue, -) -> Result { - decode_js_item::(value, "HostLocaleSubscribeItem") -} - -fn parse_host_theme_subscribe_item_item( - value: JsValue, -) -> Result { - decode_js_item::(value, "HostThemeSubscribeItem") -} From 44ed5ff4c1751ab367da718ced9dce3a7de5225e Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 08:57:03 +0000 Subject: [PATCH 2/7] ci: generate outputs on demand instead of freshness checks --- .github/workflows/ci.yml | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db542a688..26bee7b24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ permissions: jobs: rust: + needs: codegen name: Rust workspace runs-on: ubuntu-latest env: @@ -38,6 +39,11 @@ jobs: - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 + - name: Download codegen output + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: codegen-output + - name: cargo build run: cargo build --workspace --all-targets --all-features @@ -124,11 +130,14 @@ jobs: - name: Run codegen run: ./scripts/codegen.sh - - name: Check generated Rust output is committed + - name: Check no generated outputs are committed run: | - git diff --exit-code -- \ - rust/crates/truapi-server/src/generated \ - rust/crates/truapi-server/src/wasm/generated_bridge.rs + committed="$(git ls-files -ci --exclude-standard)" + if [ -n "$committed" ]; then + echo "$committed" + echo "Generated outputs above are committed. Untrack them with 'git rm --cached'." >&2 + exit 1 + fi - name: Check Rust/TS wire table parity run: TRUAPI_REQUIRE_GENERATED_TS=1 cargo test -p truapi-server --test wire_table_ts_parity @@ -146,6 +155,8 @@ jobs: js/packages/truapi/src/explorer/versions.ts js/packages/truapi-host/src/generated playground/test/generated + rust/crates/truapi-server/src/generated + rust/crates/truapi-server/src/wasm ios-bindings: name: iOS bindings (uniffi) @@ -161,19 +172,14 @@ jobs: - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 - # Swift bindgen is pure Rust codegen, so this needs neither Xcode nor the - # iOS targets, unlike rebuild.sh which also builds the xcframework. - name: Generate Swift bindings run: make uniffi - - name: Check committed iOS bindings are current - run: ./ios/truapi-host/scripts/sync-bindings.sh --check + - name: Sync iOS bindings into package + run: ./ios/truapi-host/scripts/sync-bindings.sh - # The provider ships its own UniFFI surface and its own committed - # bindings; `rebuild.sh` overwrites them in place, so only this check - # can fail on drift. - - name: Check committed TrUAPIProvider bindings are current - run: make provider-swift-check + - name: Generate TrUAPIProvider bindings + run: make provider-swift ios-changes: name: iOS change filter From 9bc37115b8f0cb519c6f40da072b454d6da2b9fd Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 08:59:56 +0000 Subject: [PATCH 3/7] docs: onboarding notes, check-generated guard, extended required list --- CONTRIBUTING.md | 2 ++ Makefile | 10 +++++++++- js/packages/truapi/scripts/ensure-generated.sh | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a65c296a0..56c037e3a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,7 @@ the full list of targets. ```bash make setup # submodules + JS dependencies +make codegen # generated Rust/TS/iOS outputs (git-ignored, regenerated from the Rust crates) make build # Rust workspace + TypeScript client ``` @@ -89,6 +90,7 @@ make playground # rebuild the playground against the refreshed snapshot make test # Rust + TypeScript client tests make check # full suite: build, fmt, clippy, test, TS tests, playground build + lint ``` +`make build` and `make check` invoke `make check-generated` first, so a missing codegen output yields a hint to run `make codegen`. ## Pull requests diff --git a/Makefile b/Makefile index e4a7687db..b65654c4e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Run `make help` for the list of targets. .DEFAULT_GOAL := help -.PHONY: help setup build codegen test check clean playground wasm wasm-crypto-test uniffi uniffi-kotlin android-check provider-android-check ios-build ios-run ios-chat-run ios-chat-host-playground-run ios-chat-all android-jni android-publish-local dotli-link dev dev-cli dev-bootstrap dev-link-check e2e-dotli e2e-cli-diagnosis e2e-signing-cli e2e-pairing-cli e2e-chat-cli e2e-cli-update headless install cli-runner cli-dist matrix explorer xcframework +.PHONY: help setup build codegen test check check-generated clean playground wasm wasm-crypto-test uniffi uniffi-kotlin android-check provider-android-check ios-build ios-run ios-chat-run ios-chat-host-playground-run ios-chat-all android-jni android-publish-local dotli-link dev dev-cli dev-bootstrap dev-link-check e2e-dotli e2e-cli-diagnosis e2e-signing-cli e2e-pairing-cli e2e-chat-cli e2e-cli-update headless install cli-runner cli-dist matrix explorer xcframework CARGO ?= cargo TRUAPI_PKG := js/packages/truapi @@ -34,6 +34,12 @@ export VITE_NETWORKS # preview behavior. DOTLI_PREVIEW ?= preview:debug +check-generated: + @test -f rust/crates/truapi-server/src/generated/dispatcher.rs \ + || { echo "Missing generated outputs. Run: make codegen"; exit 1; } + @test -f rust/crates/truapi-server/src/wasm/generated_bridge.rs \ + || { echo "Missing generated outputs. Run: make codegen"; exit 1; } + help: ## Show this help. @awk 'BEGIN { FS = ":.*##"; printf "Usage: make \n\nTargets:\n" } \ /^[a-zA-Z0-9_-]+:.*?##/ { printf " %-12s %s\n", $$1, $$2 }' $(MAKEFILE_LIST) @@ -50,6 +56,7 @@ setup: ## First-time setup: submodules, JS dependencies, generated artifacts. $(MAKE) dotli-link build: ## Build the Rust workspace and the TypeScript client. + @make check-generated cargo build --workspace cd $(TRUAPI_PKG) && npm run build cd $(HOST_WASM_PKG) && npm run build @@ -316,6 +323,7 @@ test: ## Run Rust + TypeScript client tests. cd $(HOST_WASM_PKG) && npm run build && npm test check: ## Full verification suite (build, fmt, clippy, test, TS tests, playground build + lint). + @make check-generated cargo build --workspace cargo check --target wasm32-unknown-unknown -p truapi-server cargo +nightly fmt --check diff --git a/js/packages/truapi/scripts/ensure-generated.sh b/js/packages/truapi/scripts/ensure-generated.sh index 807c07166..755ba185e 100755 --- a/js/packages/truapi/scripts/ensure-generated.sh +++ b/js/packages/truapi/scripts/ensure-generated.sh @@ -12,6 +12,8 @@ codegen_required=( "js/packages/truapi/src/playground/codegen/services.ts" "js/packages/truapi/src/explorer/codegen/types.ts" "js/packages/truapi/src/explorer/versions.ts" + "rust/crates/truapi-server/src/generated/dispatcher.rs" + "rust/crates/truapi-server/src/wasm/generated_bridge.rs" ) truapi_dts="js/packages/truapi/src/playground/codegen/truapi-dts.ts" From c4d9ab4c99bab8f642a71e36ec121d3f134f76c7 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 09:13:10 +0000 Subject: [PATCH 4/7] feat(codegen): emit mod.rs index alongside dispatcher/wire_table --- rust/crates/truapi-codegen/src/rust.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/crates/truapi-codegen/src/rust.rs b/rust/crates/truapi-codegen/src/rust.rs index 8368a82f7..215b2ea63 100644 --- a/rust/crates/truapi-codegen/src/rust.rs +++ b/rust/crates/truapi-codegen/src/rust.rs @@ -25,14 +25,16 @@ pub use wire_table::generate_wire_table; /// Generates the Rust wire dispatcher and wire-table sources into `output_dir`. pub fn generate(api: &ApiDefinition, output_dir: &Path) -> Result<()> { fs::create_dir_all(output_dir)?; + fs::write( + output_dir.join("mod.rs"), + "//! Generated by truapi-codegen. Do not edit.\n\npub mod dispatcher;\npub mod wire_table;\n", + )?; let dispatcher = generate_dispatcher(api)?; fs::write(output_dir.join("dispatcher.rs"), dispatcher)?; let wire_table = generate_wire_table(api)?; fs::write(output_dir.join("wire_table.rs"), wire_table)?; Ok(()) } - -/// Generates the Rust wasm-bindgen platform bridge source into `output_dir`. pub fn generate_wasm_bridge_file( definition: &PlatformDefinition, api: &ApiDefinition, From 8ea7ed1065e69b65829321c1cca9762cbcca62a6 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 10:12:01 +0000 Subject: [PATCH 5/7] fix(ci): generate iOS/Android outputs in every job that compiles truapi-server The untracking commits fixed only ci.yml's rust job. truapi-server declares `pub mod generated;` unconditionally, so every other job that builds it fails at parse time: ios-bindings, ios-swift, ci-android, release-android and release.yml's publish-ios. Also: - ios-swift never ran sync-bindings.sh or the js/container build, so the package had no Swift sources and no .copy resource to resolve. - the ios-changes filter keyed on an ios/ diff that generated bindings no longer produce; it now names the crates the bindings come from. - release.yml's post-rebuild `git diff --exit-code` could no longer fail. - .gitignore's truapi*.swift glob matched the hand-written TrUAPIHost.swift under core.ignorecase, which git sets by default on macOS. - check-generated is a prerequisite of every target that compiles the crate, names the missing file, and covers mod.rs and wire_table.rs. - sync-bindings.sh --check and provider-swift-check compared against files that are no longer committed. --- .github/workflows/ci-android.yml | 14 +++ .github/workflows/ci.yml | 51 +++++++-- .github/workflows/release-android.yml | 14 +++ .github/workflows/release.yml | 22 ++-- .gitignore | 4 +- CLAUDE.md | 22 ++-- CONTRIBUTING.md | 12 ++- Makefile | 47 ++++---- Package.swift | 7 +- README.md | 5 +- ios/truapi-host/README.md | 23 ++-- ios/truapi-host/scripts/rebuild.sh | 5 +- ios/truapi-host/scripts/sync-bindings.sh | 101 ++++-------------- ios/truapi-provider/scripts/rebuild.sh | 3 +- .../truapi/scripts/ensure-generated.sh | 2 + rust/crates/truapi-codegen/src/rust.rs | 5 +- .../crates/truapi-codegen/tests/golden/mod.rs | 4 + .../truapi-codegen/tests/golden_rust_emit.rs | 7 +- 18 files changed, 189 insertions(+), 159 deletions(-) create mode 100644 rust/crates/truapi-codegen/tests/golden/mod.rs diff --git a/.github/workflows/ci-android.yml b/.github/workflows/ci-android.yml index 03315326b..c228bd9d1 100644 --- a/.github/workflows/ci-android.yml +++ b/.github/workflows/ci-android.yml @@ -22,6 +22,11 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + # codegen.sh formats its generated Rust with `cargo +nightly fmt`. + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly + with: + toolchain: nightly + components: rustfmt - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2.8.1 - uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0 @@ -31,6 +36,15 @@ jobs: - uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: gradle-version: "8.9" + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: "22" + # truapi-server declares its generated modules unconditionally and they are + # gitignored, so the crate does not compile until codegen has run. + - name: Generate the Rust codegen output + run: | + npm ci --ignore-scripts + TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh - name: Generate UniFFI Kotlin bindings run: make uniffi-kotlin - name: Compile the shell against the bindings diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26bee7b24..3c758bfbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,9 +127,6 @@ jobs: - name: Install workspace deps run: npm ci --ignore-scripts - - name: Run codegen - run: ./scripts/codegen.sh - - name: Check no generated outputs are committed run: | committed="$(git ls-files -ci --exclude-standard)" @@ -139,6 +136,9 @@ jobs: exit 1 fi + - name: Run codegen + run: ./scripts/codegen.sh + - name: Check Rust/TS wire table parity run: TRUAPI_REQUIRE_GENERATED_TS=1 cargo test -p truapi-server --test wire_table_ts_parity @@ -160,6 +160,7 @@ jobs: ios-bindings: name: iOS bindings (uniffi) + needs: codegen runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -172,6 +173,16 @@ jobs: - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 + # truapi-server declares its generated modules unconditionally, so the + # cdylib bindgen builds from does not compile without the codegen output. + - name: Download codegen output + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: codegen-output + + # Swift bindgen is pure Rust codegen, so this needs neither Xcode nor the + # iOS targets, unlike rebuild.sh which also builds the xcframework. It + # gates that every UniFFI-exposed type still has a binding representation. - name: Generate Swift bindings run: make uniffi @@ -196,10 +207,10 @@ jobs: # ios-swift on the output. On pull_request the checkout is the merge # commit, so HEAD^1 is the base. Other events always run the gate. # - # The list needs no broader rust/ entry: the generated bindings are - # committed under ios/, and ios-bindings runs unconditionally, so a Rust - # change that moves the UniFFI surface either carries an ios/ change or - # fails there first. + # The bindings are generated, not committed, so a UniFFI surface change + # leaves no ios/ diff to key on. The list therefore names every crate the + # bindings are generated from, plus js/container, which is compiled into + # the TrUAPIHost target as a resource. - name: Detect iOS-relevant changes id: filter run: | @@ -209,7 +220,7 @@ jobs: exit 0 fi if git diff --name-only HEAD^1 HEAD \ - | grep -qE '^(ios/|Package\.swift$|Makefile$|rust/crates/truapi-server/src/native|rust/crates/truapi-provider/)'; then + | grep -qE '^(ios/|Package\.swift$|Makefile$|js/container/|rust/crates/truapi/|rust/crates/truapi-platform/|rust/crates/truapi-server/|rust/crates/truapi-provider/)'; then echo "ios=true" >> "$GITHUB_OUTPUT" else echo "ios=false" >> "$GITHUB_OUTPUT" @@ -217,7 +228,7 @@ jobs: ios-swift: name: iOS package (swift compile) - needs: ios-changes + needs: [ios-changes, codegen] if: needs.ios-changes.outputs.ios == 'true' runs-on: macos-15 timeout-minutes: 30 @@ -230,6 +241,10 @@ jobs: with: persist-credentials: false + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 22 + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable with: toolchain: stable @@ -239,6 +254,11 @@ jobs: with: shared-key: ios-swift-gate + - name: Download codegen output + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: codegen-output + # Simulator slice only, debug profile. This gate compiles Swift and ships # no binary, so the device slice and release codegen are waste. The # published binary is older than the current Rust surface, so @@ -246,9 +266,22 @@ jobs: - name: Build the simulator XCFramework run: make xcframework XCFRAMEWORK_TARGETS=aarch64-apple-ios-sim XCFRAMEWORK_PROFILE=debug + # make xcframework leaves the bindings in target/uniffi-swift-out; the + # package's Swift targets are gitignored, so they only exist once this + # copies them in. + - name: Sync the generated Swift bindings into the package + run: ./ios/truapi-host/scripts/sync-bindings.sh + - name: Stage it into the package run: ./ios/truapi-host/scripts/stage-xcframework.sh + # TrUAPIHost declares Resources/truapi-container.js as a .copy resource, + # so SwiftPM refuses to resolve the package until this exists. + - name: Build the lockdown container bundle + run: | + npm --prefix js/container install --no-fund --no-audit + npm --prefix js/container run build + - name: Build the simulator XCFramework for TrUAPIProvider run: PROFILE=debug ./ios/truapi-provider/scripts/rebuild.sh --sim-only diff --git a/.github/workflows/release-android.yml b/.github/workflows/release-android.yml index a2b31fa2f..bd8b02f58 100644 --- a/.github/workflows/release-android.yml +++ b/.github/workflows/release-android.yml @@ -40,6 +40,11 @@ jobs: ref: ${{ inputs.ref || github.sha }} persist-credentials: false + # codegen.sh formats its generated Rust with `cargo +nightly fmt`. + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly + with: + toolchain: nightly + components: rustfmt - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable with: targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android @@ -58,6 +63,15 @@ jobs: with: gradle-version: "8.9" + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: "22" + # truapi-server declares its generated modules unconditionally and they are + # gitignored, so the crate does not compile until codegen has run. + - name: Generate the Rust codegen output + run: | + npm ci --ignore-scripts + TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh - name: Generate UniFFI Kotlin bindings run: make uniffi-kotlin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e684e3514..615961971 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -343,6 +343,11 @@ jobs: with: node-version: "22" + # codegen.sh formats its generated Rust with `cargo +nightly fmt`. + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly + with: + toolchain: nightly + components: rustfmt - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable with: toolchain: stable @@ -351,14 +356,17 @@ jobs: with: shared-key: ios-host-release - - name: Rebuild iOS host + # truapi-server declares its generated modules unconditionally and they are + # gitignored, so the crate does not compile until codegen has run. + - name: Generate the Rust codegen output run: | - set -euo pipefail - ./ios/truapi-host/scripts/rebuild.sh - if ! git diff --exit-code; then - echo "::error::The release commit has stale generated iOS host outputs. Run ios/truapi-host/scripts/rebuild.sh and commit them." - exit 1 - fi + npm ci --ignore-scripts + TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh + + # rebuild.sh regenerates the bindings, xcframework and container bundle + # in place. They are gitignored, so there is nothing to diff against. + - name: Rebuild iOS host + run: ./ios/truapi-host/scripts/rebuild.sh - name: Test local XCFramework in the simulator env: diff --git a/.gitignore b/.gitignore index 0ab19db1f..158fd9382 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,9 @@ android/truapi-host/src/main/jniLibs/ android/truapi-provider/src/main/kotlin/generated/ android/truapi-provider/src/main/jniLibs/ # UniFFI Swift bindings and the bundled container script -ios/truapi-host/Sources/TrUAPIHost/truapi*.swift +ios/truapi-host/Sources/TrUAPIHost/truapi.swift +ios/truapi-host/Sources/TrUAPIHost/truapi_platform.swift +ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js ios/truapi-host/Sources/truapiFFI/ ios/truapi-host/Sources/truapi_platformFFI/ diff --git a/CLAUDE.md b/CLAUDE.md index d82e81527..7bc8958c0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -82,15 +82,19 @@ scripts/truapi-host-installer.sh `wasm32-unknown-unknown` to guard the wasm bridge and its offline subxt surface, but does not build or publish the packaged bundle; run `make wasm` locally before relying on the browser host. -- After changing UniFFI-exposed types or native bindings, run - `./ios/truapi-host/scripts/rebuild.sh` and commit the generated bindings and - container output. When only the bindings changed, `make uniffi && - ./ios/truapi-host/scripts/sync-bindings.sh` does that part without Xcode. CI - enforces it: the `ios-bindings` job regenerates and diffs the committed - bindings, and the `ios-swift` job compiles the package and its test target on - pull requests touching `ios/`, `Package.swift`, the `Makefile` or `native*`, - which is what catches a hand-written conformer that missed a new protocol - requirement. On the Kotlin side the `ci-android` job compiles +- The UniFFI bindings and the container bundle are gitignored build outputs. + After changing UniFFI-exposed types or native bindings, run + `./ios/truapi-host/scripts/rebuild.sh` to refresh them locally; when only the + bindings changed, `make uniffi && ./ios/truapi-host/scripts/sync-bindings.sh` + does that part without Xcode. Because nothing is committed, CI regenerates + rather than diffs: the `ios-bindings` job proves every UniFFI-exposed type + still has a binding representation, and the `ios-swift` job generates the + package's Swift sources and container resource and then compiles the package + and its test target, which is what catches a hand-written conformer that + missed a new protocol requirement. `ios-swift` is path-filtered, and the + filter has to name every crate the bindings are generated from, since a + protocol change no longer leaves an `ios/` diff to key on. On the Kotlin side + the `ci-android` job compiles `TrUAPIHost.kt` against freshly generated bindings on pull requests touching `android/` or the native crates, which catches the same class of drift; `make android-check` does it locally. The embedding apps are compiled by diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56c037e3a..764b2fb65 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,11 +69,15 @@ the full list of targets. ### Getting started ```bash -make setup # submodules + JS dependencies -make codegen # generated Rust/TS/iOS outputs (git-ignored, regenerated from the Rust crates) +make setup # submodules, JS dependencies, and the generated outputs make build # Rust workspace + TypeScript client ``` +The generated Rust, TypeScript and Swift outputs are git-ignored, so a fresh +checkout has none of them and `truapi-server` does not compile until they +exist. `make setup` produces them; `make codegen` regenerates them on their +own. + ### Making changes to the API The Rust crate in `rust/crates/truapi/` is the single source of truth for the @@ -90,7 +94,9 @@ make playground # rebuild the playground against the refreshed snapshot make test # Rust + TypeScript client tests make check # full suite: build, fmt, clippy, test, TS tests, playground build + lint ``` -`make build` and `make check` invoke `make check-generated` first, so a missing codegen output yields a hint to run `make codegen`. +Every target that compiles `truapi-server` depends on `check-generated`, so a +missing generated file names itself and points at `make codegen` instead of +failing inside rustc. ## Pull requests diff --git a/Makefile b/Makefile index b65654c4e..e948b628a 100644 --- a/Makefile +++ b/Makefile @@ -34,11 +34,18 @@ export VITE_NETWORKS # preview behavior. DOTLI_PREVIEW ?= preview:debug +# truapi-server declares these modules unconditionally, so the crate does not +# parse without them. They are gitignored and produced by scripts/codegen.sh. +GENERATED_RUST := \ + rust/crates/truapi-server/src/generated/mod.rs \ + rust/crates/truapi-server/src/generated/dispatcher.rs \ + rust/crates/truapi-server/src/generated/wire_table.rs \ + rust/crates/truapi-server/src/wasm/generated_bridge.rs + check-generated: - @test -f rust/crates/truapi-server/src/generated/dispatcher.rs \ - || { echo "Missing generated outputs. Run: make codegen"; exit 1; } - @test -f rust/crates/truapi-server/src/wasm/generated_bridge.rs \ - || { echo "Missing generated outputs. Run: make codegen"; exit 1; } + @for file in $(GENERATED_RUST); do \ + test -f "$$file" || { echo "Missing $$file. Run: make codegen"; exit 1; }; \ + done help: ## Show this help. @awk 'BEGIN { FS = ":.*##"; printf "Usage: make \n\nTargets:\n" } \ @@ -55,13 +62,12 @@ setup: ## First-time setup: submodules, JS dependencies, generated artifacts. cd $(DOTLI) && bun install --frozen-lockfile $(MAKE) dotli-link -build: ## Build the Rust workspace and the TypeScript client. - @make check-generated +build: check-generated ## Build the Rust workspace and the TypeScript client. cargo build --workspace cd $(TRUAPI_PKG) && npm run build cd $(HOST_WASM_PKG) && npm run build -headless: ## Build the truapi-host CLI and generated TypeScript client. +headless: check-generated ## Build the truapi-host CLI and generated TypeScript client. # The client build shells out to tsc, which `ensure-generated.sh` looks for at # the root or in the package. Install workspace deps when neither is present so # this target works on a checkout that has not run `make setup`. @@ -106,7 +112,7 @@ $(CLI_RUNNER): cli-runner: $(CLI_RUNNER) ## Bundle the self-contained product-script runner into target/dist. -cli-dist: $(CLI_RUNNER) ## Package truapi-host for CLI_TARGET into target/dist in the release artifact layout. +cli-dist: check-generated $(CLI_RUNNER) ## Package truapi-host for CLI_TARGET into target/dist in the release artifact layout. rustup target add $(CLI_TARGET) $(CARGO) build -p truapi-host-cli --release --target $(CLI_TARGET) rm -rf $(CLI_STAGE) @@ -120,7 +126,7 @@ codegen: ## Regenerate generated TS/Rust artifacts from the Rust crates. ./scripts/codegen.sh cd $(PLAYGROUND) && rm -rf node_modules/@parity && yarn install -wasm: ## Rebuild the truapi-server and truapi-provider WASM bundles under js/packages/*/dist/. +wasm: check-generated ## Rebuild the truapi-server and truapi-provider WASM bundles under js/packages/*/dist/. cd $(HOST_WASM_PKG) && npm run build:wasm cd $(PROVIDER_WASM_PKG) && npm run build:wasm @@ -143,9 +149,9 @@ PROVIDER_CDYLIB := $(UNIFFI_CDYLIB_DIR)/libtruapi_provider.so endif UNIFFI_SWIFT_TMP := target/uniffi-swift-out -PROVIDER_SWIFT_TMP := target/uniffi-provider-swift-check +PROVIDER_SWIFT_TMP := target/uniffi-provider-swift-out -uniffi: ## Generate Swift bindings from the truapi-server cdylib into target/uniffi-swift-out (consumed by ios/truapi-host/scripts/rebuild.sh). +uniffi: check-generated ## Generate Swift bindings from the truapi-server cdylib into target/uniffi-swift-out (consumed by ios/truapi-host/scripts/rebuild.sh). $(CARGO) build -p truapi-server --profile codegen --features ws-bridge rm -rf $(UNIFFI_SWIFT_TMP) mkdir -p $(UNIFFI_SWIFT_TMP) @@ -236,7 +242,7 @@ ios-chat-all: ios-chat-run ios-chat-host-playground-run ## Run both local iOS Ch UNIFFI_KOTLIN_OUT := android/truapi-host/src/main/kotlin/generated -uniffi-kotlin: ## Regenerate Kotlin UniFFI bindings from the truapi-server cdylib. +uniffi-kotlin: check-generated ## Regenerate Kotlin UniFFI bindings from the truapi-server cdylib. $(CARGO) build -p truapi-server --profile codegen --features ws-bridge rm -rf $(UNIFFI_KOTLIN_OUT) mkdir -p $(UNIFFI_KOTLIN_OUT) @@ -250,7 +256,7 @@ uniffi-kotlin: ## Regenerate Kotlin UniFFI bindings from the truapi-server cdyli ANDROID_ABIS ?= arm64-v8a armeabi-v7a x86_64 ANDROID_JNILIBS := android/truapi-host/src/main/jniLibs -android-jni: ## Cross-compile libtruapi_server.so for Android ABIs into jniLibs (needs cargo-ndk + NDK). +android-jni: check-generated ## Cross-compile libtruapi_server.so for Android ABIs into jniLibs (needs cargo-ndk + NDK). @command -v cargo-ndk >/dev/null || { echo "cargo-ndk not found: cargo install cargo-ndk"; exit 1; } $(CARGO) ndk $(foreach abi,$(ANDROID_ABIS),-t $(abi)) \ -o $(ANDROID_JNILIBS) \ @@ -281,16 +287,6 @@ provider-swift: ## Generate the TrUAPIProvider Swift bindings into target/uniffi --language swift \ --out-dir $(PROVIDER_SWIFT_TMP) -provider-swift-check: provider-swift ## Fail if the committed TrUAPIProvider bindings are stale. - @diff -u ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift \ - $(PROVIDER_SWIFT_TMP)/truapi_provider.swift \ - && diff -u ios/truapi-provider/Sources/truapi_providerFFI/include/truapi_providerFFI.h \ - $(PROVIDER_SWIFT_TMP)/truapi_providerFFI.h \ - && diff -u ios/truapi-provider/Sources/truapi_providerFFI/include/module.modulemap \ - $(PROVIDER_SWIFT_TMP)/truapi_providerFFI.modulemap \ - && echo "Committed TrUAPIProvider bindings are current." \ - || { echo "Committed TrUAPIProvider bindings are stale: run 'make provider-ios'."; exit 1; } - provider-ios: ## Build the TrUAPIProvider Swift bindings + xcframework (adds --sim-only via SIM_ONLY=1). bash ios/truapi-provider/scripts/rebuild.sh $(if $(SIM_ONLY),--sim-only,) @@ -317,13 +313,12 @@ provider-android-check: provider-kotlin ## Compile the provider Kotlin bindings provider-android-publish-local: provider-kotlin provider-android-jni ## Publish the self-contained provider AAR (bindings + cdylib) to ~/.m2. gradle :truapi-provider:publishReleasePublicationToMavenLocal -test: ## Run Rust + TypeScript client tests. +test: check-generated ## Run Rust + TypeScript client tests. cargo test --workspace cd $(TRUAPI_PKG) && npm test cd $(HOST_WASM_PKG) && npm run build && npm test -check: ## Full verification suite (build, fmt, clippy, test, TS tests, playground build + lint). - @make check-generated +check: check-generated ## Full verification suite (build, fmt, clippy, test, TS tests, playground build + lint). cargo build --workspace cargo check --target wasm32-unknown-unknown -p truapi-server cargo +nightly fmt --check diff --git a/Package.swift b/Package.swift index 8d53ea063..c380b2305 100644 --- a/Package.swift +++ b/Package.swift @@ -5,9 +5,10 @@ // catalog — consumed as SPM git dependencies (the manifest must live at the repo // root for that). Package sources live under ios/truapi-host/ and // ios/truapi-provider/. The two products are independent and release on separate -// tags. For both, the uniffi-generated bindings are committed build outputs -// (regenerate with the package's scripts/rebuild.sh) while the xcframework is -// gitignored and distributed as a GitHub release asset (scripts/publish.sh). +// tags. For both, the uniffi-generated bindings, the container resource and the +// xcframework are gitignored build outputs: regenerate them with the package's +// scripts/rebuild.sh, and publish the xcframework as a GitHub release asset +// with scripts/publish.sh. import Foundation import PackageDescription diff --git a/README.md b/README.md index 06282047d..fbb35ff07 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,9 @@ scripts/battery.sh Run the generated battery against both headless CLI h The Swift host adapter (the `TrUAPIHost` SPM package over the truapi-server UniFFI core) lives under [`ios/truapi-host/`](ios/truapi-host), with its SPM manifest at the repo root (`Package.swift`) so apps can consume it as a git-URL -dependency. Its `scripts/rebuild.sh` regenerates the committed bindings and -container bundle (`make xcframework` + `make uniffi`); see +dependency. The UniFFI bindings and the container bundle are gitignored build +outputs; `scripts/rebuild.sh` regenerates them along with the xcframework +(`make xcframework` + `make uniffi`); see [`ios/truapi-host/README.md`](ios/truapi-host/README.md). Native bindings expose the canonical Rust domain and protocol value types; native-only adapter types are limited to lifecycle and callback behavior. diff --git a/ios/truapi-host/README.md b/ios/truapi-host/README.md index 62f31b77b..8d44b3c6e 100644 --- a/ios/truapi-host/README.md +++ b/ios/truapi-host/README.md @@ -2,7 +2,7 @@ *Thin Swift shell over the Rust TrUAPI core (UniFFI). Wire decoding, request routing, and subscription lifecycle stay in the Rust core; products connect through the localhost WebSocket bridge.* -The package lives in the truapi repo next to the Rust core it wraps. `Package.swift` sits at the **repo root** (SPM requires that for git-URL dependencies), with all target paths pointing into `ios/truapi-host/`; the build scripts regenerate the committed outputs from this repo's workspace. +The package lives in the truapi repo next to the Rust core it wraps. `Package.swift` sits at the **repo root** (SPM requires that for git-URL dependencies), with all target paths pointing into `ios/truapi-host/`; the build scripts regenerate those target paths from this repo's workspace, because none of them are committed. ## What this package is for @@ -15,7 +15,7 @@ The `TrUAPIHost` SPM package an iOS host app imports directly. It carries: - [`js/container/`](../../js/container) — the TS lockdown container; built into `Sources/TrUAPIHost/Resources/truapi-container.js` and exposed via `ContainerScriptBundle.load()`. - `Tests/` — WS-bridge round-trip tests that boot the real Rust core. -The generated bindings and the container bundle are committed build outputs; the xcframework is **gitignored** and distributed as a GitHub release asset. Two scripts split the lifecycle: +The generated bindings, the container bundle and the xcframework are all **gitignored** build outputs, so a fresh checkout has no Swift sources for the package's targets. Run `rebuild.sh` before opening it. The xcframework is additionally distributed as a GitHub release asset. Two scripts split the lifecycle: ```bash ./scripts/rebuild.sh # regenerate xcframework + bindings + container @@ -35,19 +35,22 @@ targets: make uniffi && ./ios/truapi-host/scripts/sync-bindings.sh ``` -CI's `iOS bindings (uniffi)` job runs the same two commands with -`sync-bindings.sh --check`, which diffs the committed bindings against freshly -generated ones and writes nothing. It runs on Linux, so it verifies the -generated files only. +CI's `iOS bindings (uniffi)` job runs the same two commands. With nothing +committed to diff against, what it gates is that bindgen still produces a +binding for every UniFFI-exposed type. It runs on Linux, so it never compiles +Swift. The hand-written conformers in `TrUAPIHost.swift` and `Tests/` are covered by the `iOS package (swift compile)` job instead, which builds a simulator-only debug XCFramework from the pull request source and runs `xcodebuild -build-for-testing`. It is path-filtered to pull requests touching `ios/`, -`Package.swift`, the `Makefile` or `rust/crates/truapi-server/src/native*`. +build-for-testing`. It is path-filtered to pull requests touching `ios/`, `Package.swift`, the +`Makefile`, `js/container/`, or any of the crates the bindings are generated +from (`truapi`, `truapi-platform`, `truapi-server`, `truapi-provider`); the +filter has to name them explicitly, since a protocol change no longer shows up +as an `ios/` diff. Nothing compiles `TrUAPIHost.kt` or the embedding apps. -Run `rebuild.sh` after changing anything host-visible — the `NativeTrUApiHostRuntime` or `NativeProductExecution` methods, `HostCallbacks`, the native mirror types in `rust/crates/truapi-server/src/native*`, or `js/container/src` — and commit the regenerated bindings/container together with the source change. To publish from a release PR, add `@parity/ios-host ` to its `release:` title. After the release commit passes CI, the release workflow rebuilds and simulator-tests the XCFramework on macOS, uploads it, and makes the `Package.swift` follow-up commit only after the asset is live. `publish.sh` remains available for an ad hoc manual release. +Run `rebuild.sh` after changing anything host-visible — the `NativeTrUApiHostRuntime` or `NativeProductExecution` methods, `HostCallbacks`, the native mirror types in `rust/crates/truapi-server/src/native*`, or `js/container/src` — to refresh your local build outputs. Nothing to commit: CI regenerates them. To publish from a release PR, add `@parity/ios-host ` to its `release:` title. After the release commit passes CI, the release workflow rebuilds and simulator-tests the XCFramework on macOS, uploads it, and makes the `Package.swift` follow-up commit only after the asset is live. `publish.sh` remains available for an ad hoc manual release. For local iteration without publishing, flip `useLocalBinary = true` in the root `Package.swift` to build against `Binaries/` directly; flip it back before committing. @@ -409,5 +412,5 @@ The product page reads `window.__truapi_localhost.url` (set by the bootstrap scr `./scripts/rebuild.sh` orchestrates everything; the underlying pieces, should you need one in isolation: - **xcframework** — `make xcframework` (repo root) builds `truapi-server` for `aarch64-apple-ios` and `aarch64-apple-ios-sim` and bundles `target/truapi_server.xcframework`; the script copies it into `Binaries/` and strips the per-slice `module.modulemap` (module resolution comes from the `systemLibrary` target; the slice copy collides with other xcframeworks in Xcode's flat include dir). -- **bindings** — `make uniffi` (run automatically by `make xcframework`) emits the Swift bindings into `target/uniffi-swift-out/` via the workspace `uniffi-bindgen-cli`; `scripts/sync-bindings.sh` copies them into `Sources/TrUAPIHost/truapi_server.swift` and `Sources/truapi_serverFFI/include/`, renaming the emitted `truapi_serverFFI.modulemap` to `module.modulemap` so the SwiftPM `systemLibrary` target picks it up. `rebuild.sh` calls it, and CI's `--check` mode compares against it. +- **bindings** — `make uniffi` (run automatically by `make xcframework`) emits the Swift bindings into `target/uniffi-swift-out/` via the workspace `uniffi-bindgen-cli`; `scripts/sync-bindings.sh` copies them into `Sources/TrUAPIHost/truapi_server.swift` and `Sources/truapi_serverFFI/include/`, renaming the emitted `truapi_serverFFI.modulemap` to `module.modulemap` so the SwiftPM `systemLibrary` target picks it up. `rebuild.sh` calls it, and so does the `iOS package (swift compile)` job, which is what puts Swift sources into the package before `xcodebuild` runs. - **container** — `npm run build` in `js/container/` (repo root) bundles `src/index.ts` into `Sources/TrUAPIHost/Resources/truapi-container.js`. diff --git a/ios/truapi-host/scripts/rebuild.sh b/ios/truapi-host/scripts/rebuild.sh index 4610e71ee..6c468ff9a 100755 --- a/ios/truapi-host/scripts/rebuild.sh +++ b/ios/truapi-host/scripts/rebuild.sh @@ -15,9 +15,8 @@ TRUAPI_ROOT="$(cd "$PACKAGE_ROOT/../.." && pwd)" make -C "$TRUAPI_ROOT" xcframework -# The binding copy and normalization live in sync-bindings.sh so that CI's -# --check mode and this in-place write share one definition of what the -# committed bindings should contain. +# The binding copy and normalization live in sync-bindings.sh so that a caller +# refreshing only the bindings does not need Xcode or the iOS targets. sh "$PACKAGE_ROOT/scripts/sync-bindings.sh" # Staging the built framework lives in stage-xcframework.sh so that a caller diff --git a/ios/truapi-host/scripts/sync-bindings.sh b/ios/truapi-host/scripts/sync-bindings.sh index 2305ca71f..5483d63ff 100755 --- a/ios/truapi-host/scripts/sync-bindings.sh +++ b/ios/truapi-host/scripts/sync-bindings.sh @@ -1,13 +1,12 @@ #!/bin/sh # Copy the uniffi-generated Swift bindings from target/uniffi-swift-out into the -# TrUAPIHost package, normalizing them the way the committed files are stored. +# TrUAPIHost package, stripping the trailing whitespace UniFFI's templates emit. +# +# The bindings are gitignored build outputs, so the package's Swift targets do +# not exist until this runs. # # Requires `make uniffi` (or `make xcframework`, which depends on it) to have run # first; this script generates nothing itself. -# -# Usage: -# ./scripts/sync-bindings.sh write the bindings in place -# ./scripts/sync-bindings.sh --check report stale committed bindings, write nothing set -eu PACKAGE_ROOT="$(cd "$(dirname "$0")/.." && pwd)" @@ -16,88 +15,26 @@ UNIFFI_OUT="$TRUAPI_ROOT/target/uniffi-swift-out" NAMESPACES="truapi truapi_platform truapi_server" -CHECK_ONLY=0 -case "${1-}" in - --check) CHECK_ONLY=1 ;; - "") ;; - *) - echo "usage: $0 [--check]" >&2 - exit 2 - ;; -esac - if [ ! -d "$UNIFFI_OUT" ]; then echo "error: $UNIFFI_OUT is missing." >&2 echo "Run 'make uniffi' at the repo root first; this script only copies." >&2 exit 66 fi -# Stage into $1 (a directory root laid out like the package), so that --check -# never touches the working tree and an interrupted write cannot leave half of a -# namespace synced. -stage_bindings() { - dest="$1" - for namespace in $NAMESPACES; do - mkdir -p "$dest/Sources/TrUAPIHost" "$dest/Sources/${namespace}FFI/include" - cp "$UNIFFI_OUT/${namespace}.swift" \ - "$dest/Sources/TrUAPIHost/${namespace}.swift" - cp "$UNIFFI_OUT/${namespace}FFI.h" \ - "$dest/Sources/${namespace}FFI/include/${namespace}FFI.h" - cp "$UNIFFI_OUT/${namespace}FFI.modulemap" \ - "$dest/Sources/${namespace}FFI/include/module.modulemap" - # UniFFI templates emit trailing spaces around optional fragments. Keep the - # committed bindings stable so rebuilding only records API changes. - perl -pi -e 's/[ \t]+$//' \ - "$dest/Sources/TrUAPIHost/${namespace}.swift" \ - "$dest/Sources/${namespace}FFI/include/${namespace}FFI.h" \ - "$dest/Sources/${namespace}FFI/include/module.modulemap" - done -} - -relative_paths() { - for namespace in $NAMESPACES; do - echo "Sources/TrUAPIHost/${namespace}.swift" - echo "Sources/${namespace}FFI/include/${namespace}FFI.h" - echo "Sources/${namespace}FFI/include/module.modulemap" - done -} - -if [ "$CHECK_ONLY" -eq 0 ]; then - stage_bindings "$PACKAGE_ROOT" - echo "Bindings synced into $PACKAGE_ROOT/Sources" - exit 0 -fi - -STAGING="$(mktemp -d)" -trap 'rm -rf "$STAGING"' EXIT -stage_bindings "$STAGING" - -stale=0 -# Report every stale file rather than stopping at the first: a HostCallbacks -# change usually touches all three namespaces, and one-at-a-time reporting -# invites partial fixes. -for path in $(relative_paths); do - if ! diff -u "$PACKAGE_ROOT/$path" "$STAGING/$path" \ - --label "committed/$path" --label "generated/$path"; then - stale=$((stale + 1)) - fi +for namespace in $NAMESPACES; do + mkdir -p "$PACKAGE_ROOT/Sources/TrUAPIHost" \ + "$PACKAGE_ROOT/Sources/${namespace}FFI/include" + cp "$UNIFFI_OUT/${namespace}.swift" \ + "$PACKAGE_ROOT/Sources/TrUAPIHost/${namespace}.swift" + cp "$UNIFFI_OUT/${namespace}FFI.h" \ + "$PACKAGE_ROOT/Sources/${namespace}FFI/include/${namespace}FFI.h" + # The SwiftPM systemLibrary target looks for module.modulemap by name. + cp "$UNIFFI_OUT/${namespace}FFI.modulemap" \ + "$PACKAGE_ROOT/Sources/${namespace}FFI/include/module.modulemap" + perl -pi -e 's/[ \t]+$//' \ + "$PACKAGE_ROOT/Sources/TrUAPIHost/${namespace}.swift" \ + "$PACKAGE_ROOT/Sources/${namespace}FFI/include/${namespace}FFI.h" \ + "$PACKAGE_ROOT/Sources/${namespace}FFI/include/module.modulemap" done -if [ "$stale" -ne 0 ]; then - cat >&2 <<'EOF' - -error: the committed iOS bindings do not match the current Rust surface. - -Regenerate and commit them: - - make uniffi && ./ios/truapi-host/scripts/sync-bindings.sh - -Regenerating alone is usually not enough: the hand-written conformers -(ios/truapi-host/Sources/TrUAPIHost/TrUAPIHost.swift and -android/truapi-host/.../TrUAPIHost.kt) need a matching change whenever -HostCallbacks gains or changes a requirement. -EOF - exit 1 -fi - -echo "Committed iOS bindings are current." +echo "Bindings synced into $PACKAGE_ROOT/Sources" diff --git a/ios/truapi-provider/scripts/rebuild.sh b/ios/truapi-provider/scripts/rebuild.sh index 35410ec62..6357b4b26 100755 --- a/ios/truapi-provider/scripts/rebuild.sh +++ b/ios/truapi-provider/scripts/rebuild.sh @@ -5,7 +5,8 @@ # (Sources/TrUAPIProvider + Sources/truapi_providerFFI) # # Run after changing the crate's uniffi surface or refreshing the bundled chain -# specs, and commit the regenerated bindings with the source change. +# specs. The outputs are gitignored, so the package's Swift target does not +# exist until this has run. # Usage: ./scripts/rebuild.sh [--sim-only] # # --sim-only drops the device slice for a faster loop; publish.sh rejects the diff --git a/js/packages/truapi/scripts/ensure-generated.sh b/js/packages/truapi/scripts/ensure-generated.sh index 755ba185e..ea57a6786 100755 --- a/js/packages/truapi/scripts/ensure-generated.sh +++ b/js/packages/truapi/scripts/ensure-generated.sh @@ -12,7 +12,9 @@ codegen_required=( "js/packages/truapi/src/playground/codegen/services.ts" "js/packages/truapi/src/explorer/codegen/types.ts" "js/packages/truapi/src/explorer/versions.ts" + "rust/crates/truapi-server/src/generated/mod.rs" "rust/crates/truapi-server/src/generated/dispatcher.rs" + "rust/crates/truapi-server/src/generated/wire_table.rs" "rust/crates/truapi-server/src/wasm/generated_bridge.rs" ) truapi_dts="js/packages/truapi/src/playground/codegen/truapi-dts.ts" diff --git a/rust/crates/truapi-codegen/src/rust.rs b/rust/crates/truapi-codegen/src/rust.rs index 215b2ea63..ac290f28b 100644 --- a/rust/crates/truapi-codegen/src/rust.rs +++ b/rust/crates/truapi-codegen/src/rust.rs @@ -22,7 +22,8 @@ pub use dispatcher::generate_dispatcher; pub use wasm_bridge::generate_wasm_bridge; pub use wire_table::generate_wire_table; -/// Generates the Rust wire dispatcher and wire-table sources into `output_dir`. +/// Generates the `truapi-server` wire dispatcher, wire table, and the `mod.rs` +/// that declares them, into `output_dir`. pub fn generate(api: &ApiDefinition, output_dir: &Path) -> Result<()> { fs::create_dir_all(output_dir)?; fs::write( @@ -35,6 +36,8 @@ pub fn generate(api: &ApiDefinition, output_dir: &Path) -> Result<()> { fs::write(output_dir.join("wire_table.rs"), wire_table)?; Ok(()) } + +/// Generates the Rust wasm-bindgen platform bridge source into `output_dir`. pub fn generate_wasm_bridge_file( definition: &PlatformDefinition, api: &ApiDefinition, diff --git a/rust/crates/truapi-codegen/tests/golden/mod.rs b/rust/crates/truapi-codegen/tests/golden/mod.rs new file mode 100644 index 000000000..770a015d0 --- /dev/null +++ b/rust/crates/truapi-codegen/tests/golden/mod.rs @@ -0,0 +1,4 @@ +//! Generated by truapi-codegen. Do not edit. + +pub mod dispatcher; +pub mod wire_table; diff --git a/rust/crates/truapi-codegen/tests/golden_rust_emit.rs b/rust/crates/truapi-codegen/tests/golden_rust_emit.rs index 429d30346..e0b46eecb 100644 --- a/rust/crates/truapi-codegen/tests/golden_rust_emit.rs +++ b/rust/crates/truapi-codegen/tests/golden_rust_emit.rs @@ -198,13 +198,16 @@ fn golden_dispatcher_and_wire_table() { String::from_utf8_lossy(&out.stderr), ); - // Compare both emitted files against the goldens. We assert on + // Compare the emitted files against the goldens. We assert on // wire_table.rs first because it's small and the diff is easy to - // read when the wire ids drift. + // read when the wire ids drift. mod.rs is covered because + // truapi-server declares `pub mod generated;` unconditionally, so + // dropping it stops the crate parsing at all. let golden_dir = manifest_dir.join("tests/golden"); let cases = [ ("wire_table.rs", "wire_table.rs"), ("dispatcher.rs", "dispatcher.rs"), + ("mod.rs", "mod.rs"), ]; for (golden_name, output_name) in cases { let golden = fs::read_to_string(golden_dir.join(golden_name)) From 4c9311144297bbe97d5883a066a4be1388e3246d Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 15:03:47 +0000 Subject: [PATCH 6/7] feat(ios): publish the SwiftPM consumer tag from CI SwiftPM resolves source targets from the git checkout, so a branch that ignores the generated bindings cannot be consumed. A release is now two artifacts: the xcframework as a release asset, and a plain semver tag whose commit carries the generated sources plus a manifest pointing at that asset. Consumers keep the same URL and the same exact() pin. publish-ios moves into release-ios.yml so it is callable from release.yml and dispatchable for a pre-release, matching release-android.yml. The tag is verified by cloning and building it before the push. tag-release.sh reads the required paths out of Package.swift so the file set cannot drift from what SwiftPM looks for. Also fixes the manifest guard: 9b708fb5 replaced 'let useLocalBinary = false' with the ProcessInfo form, but release.yml still grepped for the literal, so the follow-up commit step could never pass. --- .github/workflows/release-ios.yml | 234 +++++++++++++++++++ .github/workflows/release.yml | 135 +---------- ios/truapi-host/scripts/tag-release.sh | 72 ++++++ ios/truapi-provider/scripts/rebuild.sh | 9 +- ios/truapi-provider/scripts/sync-bindings.sh | 34 +++ 5 files changed, 346 insertions(+), 138 deletions(-) create mode 100644 .github/workflows/release-ios.yml create mode 100755 ios/truapi-host/scripts/tag-release.sh create mode 100755 ios/truapi-provider/scripts/sync-bindings.sh diff --git a/.github/workflows/release-ios.yml b/.github/workflows/release-ios.yml new file mode 100644 index 000000000..f89ca74ba --- /dev/null +++ b/.github/workflows/release-ios.yml @@ -0,0 +1,234 @@ +# Publishes the TrUAPIHost XCFramework and the tag SwiftPM consumers resolve. +# +# The repo git-ignores the generated bindings and the container bundle, but a +# SwiftPM consumer resolves source targets from the git checkout. So a release +# is two artifacts, not one: the xcframework as a GitHub release asset, and a +# plain semver tag whose commit carries the generated sources and a manifest +# pointing at that asset. Consumers pin the semver tag. +name: release-ios + +on: + # release.yml calls this for a `release: @parity/ios-host ` commit + # subject, so the release flow and a manual publish produce the same tag. + workflow_call: + inputs: + version: + description: "Version to publish" + required: true + type: string + ref: + description: "Commit to build, since a called workflow does not inherit the caller's checkout" + required: true + type: string + manifest_branch: + description: "Branch to land the Package.swift follow-up commit on; empty to skip it" + required: false + default: "" + type: string + # Manual escape hatch, and the way to cut a pre-release for app-side testing + # of an unmerged change. There is deliberately no tag trigger: a tag push + # cannot use release.yml's workflow_run gate on green CI. + workflow_dispatch: + inputs: + version: + description: "Version to publish (e.g. 0.12.0 or 0.12.0-beta.1)" + required: true + type: string + +permissions: + contents: read + +jobs: + publish: + name: Publish iOS host + runs-on: macos-15 + timeout-minutes: 60 + permissions: + contents: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + ref: ${{ inputs.ref || github.sha }} + persist-credentials: false + + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: "22" + + # codegen.sh formats its generated Rust with `cargo +nightly fmt`. + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly + with: + toolchain: nightly + components: rustfmt + + - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable + with: + toolchain: stable + + - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 + with: + shared-key: ios-host-release + + # truapi-server declares its generated modules unconditionally and they are + # gitignored, so the crate does not compile until codegen has run. + - name: Generate the Rust codegen output + run: | + npm ci --ignore-scripts + TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh + + # Bindings, xcframework and the container bundle for the host. + - name: Rebuild iOS host + run: ./ios/truapi-host/scripts/rebuild.sh + + # Package.swift declares TrUAPIProvider as a source target, so its + # bindings have to exist even for a consumer that only imports + # TrUAPIHost. Generating them needs no Xcode and no iOS targets. + - name: Generate TrUAPIProvider bindings + run: | + make provider-swift + ./ios/truapi-provider/scripts/sync-bindings.sh + + - name: Test local XCFramework in the simulator + env: + TRUAPI_USE_LOCAL_BINARY: "1" + run: | + set -euo pipefail + xcodebuild test \ + -scheme TrUAPIHost \ + -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \ + -derivedDataPath "$RUNNER_TEMP/TrUAPIHostDerivedData" \ + CODE_SIGNING_ALLOWED=NO + + - name: Publish XCFramework + id: ios_publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IOS_RELEASE_TARGET: ${{ inputs.ref || github.sha }} + IOS_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + + read_manifest_value() { + sed -n -E "s/^let $1 = \"([^\"]+)\"$/\1/p" Package.swift + } + + base_url="$(read_manifest_value publishedBinaryURL)" + base_checksum="$(read_manifest_value publishedBinaryChecksum)" + ./ios/truapi-host/scripts/publish.sh "${IOS_VERSION}" + published_url="$(read_manifest_value publishedBinaryURL)" + published_checksum="$(read_manifest_value publishedBinaryChecksum)" + + { + echo "base_url=${base_url}" + echo "base_checksum=${base_checksum}" + echo "published_url=${published_url}" + echo "published_checksum=${published_checksum}" + } >> "$GITHUB_OUTPUT" + + # The consumer artifact. Commits the generated sources and the manifest + # that now points at the asset uploaded above, and tags it. + - name: Build the SwiftPM consumer tag + env: + IOS_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + ./ios/truapi-host/scripts/tag-release.sh "${IOS_VERSION}" + + # Resolve and compile the tag exactly as a consumer would, from a clean + # clone with no build outputs, before the tag is pushed. A tag that + # cannot be resolved is worse than no tag, so this gates the push. + - name: Verify the tag resolves as a consumer + env: + IOS_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + probe="$RUNNER_TEMP/tag-probe" + rm -rf "$probe" + git clone --quiet --branch "${IOS_VERSION}" "file://$PWD" "$probe" + + missing=0 + while read -r path; do + [ -e "$probe/$path" ] || { echo "::error::$path missing from tag"; missing=1; } + done <<< "$(sed -n -E 's/^[[:space:]]*path: "([^"]+)".*/\1/p' "$probe/Package.swift" | grep -v '/Binaries/')" + [ -e "$probe/ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js" ] \ + || { echo "::error::container resource missing from tag"; missing=1; } + [ "$missing" -eq 0 ] + + # No TRUAPI_USE_LOCAL_BINARY here on purpose: this must exercise the + # published asset and its checksum, like a real consumer. + cd "$probe" + xcodebuild build \ + -scheme TrUAPIHost \ + -destination 'generic/platform=iOS Simulator' \ + -derivedDataPath "$RUNNER_TEMP/TagProbeDerivedData" \ + CODE_SIGNING_ALLOWED=NO + + - name: Push the tag + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IOS_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + gh auth setup-git + git push origin "refs/tags/${IOS_VERSION}" + + # Keeps the branch's manifest pointing at the newest asset so a local + # build with useLocalBinary off resolves it. Skipped for a dispatched + # pre-release, which must not rewrite anyone's branch. + - name: Commit published manifest + if: inputs.manifest_branch != '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IOS_VERSION: ${{ inputs.version }} + RELEASE_BRANCH: ${{ inputs.manifest_branch }} + BASE_URL: ${{ steps.ios_publish.outputs.base_url }} + BASE_CHECKSUM: ${{ steps.ios_publish.outputs.base_checksum }} + PUBLISHED_URL: ${{ steps.ios_publish.outputs.published_url }} + PUBLISHED_CHECKSUM: ${{ steps.ios_publish.outputs.published_checksum }} + run: | + set -euo pipefail + + read_manifest_value() { + sed -n -E "s/^let $1 = \"([^\"]+)\"$/\1/p" Package.swift + } + + git fetch origin "${RELEASE_BRANCH}" + git switch --force-create ios-manifest-update "origin/${RELEASE_BRANCH}" + + current_url="$(read_manifest_value publishedBinaryURL)" + current_checksum="$(read_manifest_value publishedBinaryChecksum)" + if [ "${current_url}" = "${PUBLISHED_URL}" ] && [ "${current_checksum}" = "${PUBLISHED_CHECKSUM}" ]; then + echo "Package.swift already references @parity/ios-host@${IOS_VERSION}." + exit 0 + fi + if [ "${current_url}" != "${BASE_URL}" ] || [ "${current_checksum}" != "${BASE_CHECKSUM}" ]; then + echo "::error::Package.swift changed after the release commit; refusing to overwrite the newer manifest." + exit 1 + fi + + sed -i '' -E "s|^let publishedBinaryURL = .*|let publishedBinaryURL = \"${PUBLISHED_URL}\"|" Package.swift + sed -i '' -E "s|^let publishedBinaryChecksum = .*|let publishedBinaryChecksum = \"${PUBLISHED_CHECKSUM}\"|" Package.swift + grep -q '^let useLocalBinary = ProcessInfo' Package.swift + + git add Package.swift + git commit -m "build(ios): publish host XCFramework ${IOS_VERSION}" + + gh auth setup-git + attempt=1 + until git push origin "HEAD:${RELEASE_BRANCH}" + do + if [ "${attempt}" -ge 3 ]; then + echo "::error::Could not push the Package.swift follow-up commit." + exit 1 + fi + attempt=$((attempt + 1)) + git fetch origin "${RELEASE_BRANCH}" + if ! git rebase "origin/${RELEASE_BRANCH}"; then + git rebase --abort + echo "::error::Package.swift changed while publishing; resolve the manifest update manually." + exit 1 + fi + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 615961971..74112bc4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -329,135 +329,10 @@ jobs: name: Publish iOS host needs: release if: needs.release.outputs.ios_version != '' - runs-on: macos-15 permissions: contents: write - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - ref: ${{ github.event.workflow_run.head_sha }} - persist-credentials: false - - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: "22" - - # codegen.sh formats its generated Rust with `cargo +nightly fmt`. - - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly - with: - toolchain: nightly - components: rustfmt - - uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable - with: - toolchain: stable - - - uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 - with: - shared-key: ios-host-release - - # truapi-server declares its generated modules unconditionally and they are - # gitignored, so the crate does not compile until codegen has run. - - name: Generate the Rust codegen output - run: | - npm ci --ignore-scripts - TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh - - # rebuild.sh regenerates the bindings, xcframework and container bundle - # in place. They are gitignored, so there is nothing to diff against. - - name: Rebuild iOS host - run: ./ios/truapi-host/scripts/rebuild.sh - - - name: Test local XCFramework in the simulator - env: - TRUAPI_USE_LOCAL_BINARY: "1" - run: | - set -euo pipefail - xcodebuild test \ - -scheme TrUAPIHost \ - -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \ - -derivedDataPath "$RUNNER_TEMP/TrUAPIHostDerivedData" \ - CODE_SIGNING_ALLOWED=NO - - - name: Publish XCFramework - id: ios_publish - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IOS_RELEASE_TARGET: ${{ github.event.workflow_run.head_sha }} - IOS_VERSION: ${{ needs.release.outputs.ios_version }} - run: | - set -euo pipefail - - read_manifest_value() { - sed -n -E "s/^let $1 = \"([^\"]+)\"$/\1/p" Package.swift - } - - base_url="$(read_manifest_value publishedBinaryURL)" - base_checksum="$(read_manifest_value publishedBinaryChecksum)" - ./ios/truapi-host/scripts/publish.sh "${IOS_VERSION}" - published_url="$(read_manifest_value publishedBinaryURL)" - published_checksum="$(read_manifest_value publishedBinaryChecksum)" - - { - echo "base_url=${base_url}" - echo "base_checksum=${base_checksum}" - echo "published_url=${published_url}" - echo "published_checksum=${published_checksum}" - } >> "$GITHUB_OUTPUT" - - - name: Commit published manifest - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IOS_VERSION: ${{ needs.release.outputs.ios_version }} - RELEASE_BRANCH: ${{ github.event.workflow_run.head_branch }} - BASE_URL: ${{ steps.ios_publish.outputs.base_url }} - BASE_CHECKSUM: ${{ steps.ios_publish.outputs.base_checksum }} - PUBLISHED_URL: ${{ steps.ios_publish.outputs.published_url }} - PUBLISHED_CHECKSUM: ${{ steps.ios_publish.outputs.published_checksum }} - run: | - set -euo pipefail - - read_manifest_value() { - sed -n -E "s/^let $1 = \"([^\"]+)\"$/\1/p" Package.swift - } - - git restore Package.swift - git fetch origin "${RELEASE_BRANCH}" - git switch --force-create ios-manifest-update "origin/${RELEASE_BRANCH}" - - current_url="$(read_manifest_value publishedBinaryURL)" - current_checksum="$(read_manifest_value publishedBinaryChecksum)" - if [ "${current_url}" = "${PUBLISHED_URL}" ] && [ "${current_checksum}" = "${PUBLISHED_CHECKSUM}" ]; then - echo "Package.swift already references @parity/ios-host@${IOS_VERSION}." - exit 0 - fi - if [ "${current_url}" != "${BASE_URL}" ] || [ "${current_checksum}" != "${BASE_CHECKSUM}" ]; then - echo "::error::Package.swift changed after the release commit; refusing to overwrite the newer manifest." - exit 1 - fi - - sed -i '' -E "s|^let publishedBinaryURL = .*|let publishedBinaryURL = \"${PUBLISHED_URL}\"|" Package.swift - sed -i '' -E "s|^let publishedBinaryChecksum = .*|let publishedBinaryChecksum = \"${PUBLISHED_CHECKSUM}\"|" Package.swift - grep -q '^let useLocalBinary = false$' Package.swift - - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add Package.swift - git commit -m "build(ios): publish host XCFramework ${IOS_VERSION}" - - gh auth setup-git - attempt=1 - until git push origin "HEAD:${RELEASE_BRANCH}" - do - if [ "${attempt}" -ge 3 ]; then - echo "::error::Could not push the Package.swift follow-up commit." - exit 1 - fi - attempt=$((attempt + 1)) - git fetch origin "${RELEASE_BRANCH}" - if ! git rebase "origin/${RELEASE_BRANCH}"; then - git rebase --abort - echo "::error::Package.swift changed while publishing; resolve the manifest update manually." - exit 1 - fi - done + uses: ./.github/workflows/release-ios.yml + with: + version: ${{ needs.release.outputs.ios_version }} + ref: ${{ github.event.workflow_run.head_sha }} + manifest_branch: ${{ github.event.workflow_run.head_branch }} diff --git a/ios/truapi-host/scripts/tag-release.sh b/ios/truapi-host/scripts/tag-release.sh new file mode 100755 index 000000000..defd6639f --- /dev/null +++ b/ios/truapi-host/scripts/tag-release.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Create the tag a SwiftPM consumer resolves. +# +# SwiftPM resolves a package's source targets from the git checkout and has no +# way to fetch them from a release asset, so a branch that git-ignores the +# generated bindings cannot be consumed directly. The tag commit carries them: +# the manifest pointing at the published xcframework, plus every source path +# Package.swift declares. +# +# Usage: ./scripts/tag-release.sh +# +# Expects the generated outputs to be present already: rebuild.sh for the host, +# scripts/sync-bindings.sh under ios/truapi-provider for the provider, and the +# js/container build for the lockdown resource. Creates the commit and tag +# locally; pushing is the caller's decision. +set -eu + +if [ $# -ne 1 ]; then + echo "usage: $0 " >&2 + exit 64 +fi + +VERSION="$1" +TRUAPI_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)" +cd "$TRUAPI_ROOT" + +if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null 2>&1; then + echo "error: tag ${VERSION} already exists" >&2 + exit 65 +fi + +# Read the paths out of the manifest rather than repeating them, so this cannot +# drift from what SwiftPM will look for. Binaries/ is excluded: only the +# useLocalBinary branch names it, and a published manifest never takes that +# branch. +manifest_paths() { + sed -n -E 's/^[[:space:]]*path: "([^"]+)".*/\1/p' Package.swift | grep -v '/Binaries/' +} + +if ! grep -q '^let useLocalBinary = ProcessInfo' Package.swift; then + echo "error: Package.swift does not read TRUAPI_USE_LOCAL_BINARY from the environment;" >&2 + echo "a published manifest must never pin the local binary." >&2 + exit 65 +fi + +missing="" +for path in $(manifest_paths); do + [ -e "${path}" ] || missing="${missing} ${path}" +done +if [ -n "${missing}" ]; then + echo "error: Package.swift declares paths that do not exist:${missing}" >&2 + echo "Generate them first (ios/truapi-host/scripts/rebuild.sh," >&2 + echo "ios/truapi-provider/scripts/sync-bindings.sh, npm -w js/container run build)." >&2 + exit 66 +fi + +for path in $(manifest_paths); do + git add --force -- "${path}" +done +git add -- Package.swift + +# The xcframework ships as a release asset. Tagging one into git would add +# tens of megabytes to every consumer's clone. +if git diff --cached --name-only | grep -q '/Binaries/'; then + echo "error: refusing to tag an xcframework into git" >&2 + exit 65 +fi + +git commit -q -m "release(ios): TrUAPIHost ${VERSION}" +git tag "${VERSION}" + +echo "Tagged ${VERSION} at $(git rev-parse --short HEAD) with $(git ls-tree -r --name-only HEAD -- ios | wc -l | tr -d ' ') files under ios/" diff --git a/ios/truapi-provider/scripts/rebuild.sh b/ios/truapi-provider/scripts/rebuild.sh index 6357b4b26..d77822816 100755 --- a/ios/truapi-provider/scripts/rebuild.sh +++ b/ios/truapi-provider/scripts/rebuild.sh @@ -42,14 +42,7 @@ cargo run -q -p uniffi-bindgen-cli -- generate \ --language swift \ --out-dir "$UNIFFI_OUT" -mkdir -p "$PACKAGE_ROOT/Sources/TrUAPIProvider" \ - "$PACKAGE_ROOT/Sources/truapi_providerFFI/include" -cp "$UNIFFI_OUT/truapi_provider.swift" \ - "$PACKAGE_ROOT/Sources/TrUAPIProvider/truapi_provider.swift" -cp "$UNIFFI_OUT/truapi_providerFFI.h" \ - "$PACKAGE_ROOT/Sources/truapi_providerFFI/include/truapi_providerFFI.h" -cp "$UNIFFI_OUT/truapi_providerFFI.modulemap" \ - "$PACKAGE_ROOT/Sources/truapi_providerFFI/include/module.modulemap" +PROVIDER_UNIFFI_OUT="$UNIFFI_OUT" sh "$PACKAGE_ROOT/scripts/sync-bindings.sh" # The xcframework carries the headers; the systemLibrary target above reads the # committed copies, so both must come from this same generation. diff --git a/ios/truapi-provider/scripts/sync-bindings.sh b/ios/truapi-provider/scripts/sync-bindings.sh new file mode 100755 index 000000000..d78cfcbb3 --- /dev/null +++ b/ios/truapi-provider/scripts/sync-bindings.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Copy the uniffi-generated Swift bindings from target/uniffi-provider-swift-out +# into the TrUAPIProvider package. +# +# The bindings are gitignored build outputs, so the package's Swift targets do +# not exist until this runs. Split out of rebuild.sh so a caller that only needs +# the sources (the release tag, CI's compile gate) does not have to build an +# xcframework, which needs Xcode and the iOS targets. +# +# Requires `make provider-swift` (or rebuild.sh, which generates the same +# directory) to have run first; this script generates nothing itself. +set -eu + +PACKAGE_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +TRUAPI_ROOT="$(cd "$PACKAGE_ROOT/../.." && pwd)" +UNIFFI_OUT="${PROVIDER_UNIFFI_OUT:-$TRUAPI_ROOT/target/uniffi-provider-swift-out}" + +if [ ! -d "$UNIFFI_OUT" ]; then + echo "error: $UNIFFI_OUT is missing." >&2 + echo "Run 'make provider-swift' at the repo root first; this script only copies." >&2 + exit 66 +fi + +mkdir -p "$PACKAGE_ROOT/Sources/TrUAPIProvider" \ + "$PACKAGE_ROOT/Sources/truapi_providerFFI/include" +cp "$UNIFFI_OUT/truapi_provider.swift" \ + "$PACKAGE_ROOT/Sources/TrUAPIProvider/truapi_provider.swift" +cp "$UNIFFI_OUT/truapi_providerFFI.h" \ + "$PACKAGE_ROOT/Sources/truapi_providerFFI/include/truapi_providerFFI.h" +# The SwiftPM systemLibrary target looks for module.modulemap by name. +cp "$UNIFFI_OUT/truapi_providerFFI.modulemap" \ + "$PACKAGE_ROOT/Sources/truapi_providerFFI/include/module.modulemap" + +echo "Provider bindings synced into $PACKAGE_ROOT/Sources" From f514787aeff319cb67b908dd46695c890e6d71ab Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 29 Aug 2026 15:05:04 +0000 Subject: [PATCH 7/7] docs(ios): describe the two-artifact release and the SwiftPM tag Also compiles the ios-swift CI gate from a clean clone of the tag rather than in place, so a generated file the tag does not carry fails the PR instead of the next consumer. --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++------ CLAUDE.md | 12 ++++++++---- docs/RELEASE_PROCESS.md | 28 +++++++++++++++++++++++++--- ios/truapi-host/README.md | 14 ++++++++++++++ 4 files changed, 79 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c758bfbb..7fbdf5502 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -285,18 +285,44 @@ jobs: - name: Build the simulator XCFramework for TrUAPIProvider run: PROFILE=debug ./ios/truapi-provider/scripts/rebuild.sh --sim-only - # Compiling the test target is the point: the hand-written conformers a - # generated-file diff cannot see live there and in TrUAPIHost.swift. - - name: Compile the package and its tests + # Build the tag a release would cut, then compile from a clean clone of + # it. Compiling in place would pass on generated files that the tag does + # not carry, which is exactly the failure this guards: a consumer only + # ever sees the tag. + - name: Build the SwiftPM consumer tag run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + ./ios/truapi-host/scripts/tag-release.sh 0.0.0-ci + + - name: Check the tag carries every generated file + run: | + set -euo pipefail + probe="$RUNNER_TEMP/tag-probe" + rm -rf "$probe" + git clone --quiet --branch 0.0.0-ci "file://$PWD" "$probe" + while read -r path; do + diff -u <(cd "$probe" && find "$path" -type f | sort) \ + <(find "$path" -type f | sort) + done <<< "$(sed -n -E 's/^[[:space:]]*path: "([^"]+)".*/\1/p' Package.swift | grep -v '/Binaries/')" + + # The xcframework ships as a release asset rather than in the tag, so the + # locally built one stands in for it here. + - name: Compile the package and its tests from the tag + run: | + set -euo pipefail + probe="$RUNNER_TEMP/tag-probe" + mkdir -p "$probe/ios/truapi-host/Binaries" "$probe/ios/truapi-provider/Binaries" + cp -R ios/truapi-host/Binaries/truapi_server.xcframework "$probe/ios/truapi-host/Binaries/" + cp -R ios/truapi-provider/Binaries/truapi_provider.xcframework "$probe/ios/truapi-provider/Binaries/" + cd "$probe" xcodebuild build-for-testing \ -scheme TrUAPIHost \ -destination 'generic/platform=iOS Simulator' \ -derivedDataPath "$RUNNER_TEMP/TrUAPIHostDerivedData" \ CODE_SIGNING_ALLOWED=NO - - - name: Compile TrUAPIProvider - run: swift build --target TrUAPIProvider + swift build --target TrUAPIProvider ts-client: name: "@parity/truapi" diff --git a/CLAUDE.md b/CLAUDE.md index 7bc8958c0..dd065f62e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -101,10 +101,14 @@ scripts/truapi-host-installer.sh neither. Hosts implement `HostBridge`, whose protocol extension defaults the optional callbacks; `TrUAPIHostRuntime` and each product execution retain one. - To publish the binary, include `@parity/ios-host ` - in the `release:` PR title. The release workflow rebuilds and simulator-tests - the XCFramework, uploads it, and makes the `Package.swift` follow-up commit - only after the asset is live. When the title also names an npm package, the + To publish, include `@parity/ios-host ` in the `release:` PR title. + `release-ios.yml` rebuilds and simulator-tests the XCFramework, uploads it, + then cuts the plain semver tag `` whose commit carries the generated + sources and a manifest pointing at that asset. That tag is the SwiftPM + contract: consumers pin `exact("")`, and a branch cannot be consumed + directly because the generated sources are ignored there. The job clones and + compiles the tag before pushing it. Dispatching `release-ios` manually with a + pre-release version cuts a tag for app-side testing of an unmerged change. When the title also names an npm package, the iOS job waits on that publish being confirmed on npm. `publish.sh ` is the manual fallback. Keep `useLocalBinary = false` in committed manifests; `true` is for local diff --git a/docs/RELEASE_PROCESS.md b/docs/RELEASE_PROCESS.md index 01ebd1873..89523d9fc 100644 --- a/docs/RELEASE_PROCESS.md +++ b/docs/RELEASE_PROCESS.md @@ -117,6 +117,24 @@ each archive and its `.sha256` to the `@parity/truapi@` release, and only then moves the `truapi-host-cli-stable` pointer that the installer and the in-binary updater read. There is no separate release subject entry for it. +`@parity/ios-host ` publishes two artifacts, because SwiftPM splits a +package across both. The xcframework goes to the `@parity/ios-host@` +GitHub release as an asset. The Swift sources go to a plain semver tag named +``, whose commit carries the generated bindings, the FFI headers and +the container bundle alongside a `Package.swift` pointing at that asset. The +generated files are git-ignored on a branch, and SwiftPM resolves source +targets from the git checkout with no way to fetch them from an asset, so the +tag is what a consumer can actually resolve. Apps therefore pin the semver tag: + +```swift +.package(url: "https://github.com/paritytech/host-rust-core", exact: "0.12.0") +``` + +`ios/truapi-host/scripts/tag-release.sh` builds that commit, reading the +required paths out of `Package.swift` so the file set cannot drift from what +SwiftPM looks for. The job clones the tag and compiles it against the published +asset before pushing, so a tag that cannot be resolved is never published. + `@parity/android-host ` publishes the Android host AAR as `io.parity:truapi-host-android:` to GitHub Packages. The job cross-compiles `libtruapi_server.so` for arm64-v8a, armeabi-v7a and x86_64, @@ -128,9 +146,13 @@ release subject is the only place it appears. See consumer setup and the credentials a consumer needs. Both native jobs are also reachable by a manual `workflow_dispatch` run with a -version input, as an escape hatch. Neither has a tag trigger, because a tag push -cannot use the `workflow_run` gate on green CI and would be an unverified path to -a registry. +version input. For iOS that is also how a pre-release is cut: dispatching +`release-ios` from a branch with a version like `0.12.0-beta.1` publishes an +asset and a tag an app can pin, which is how an unmerged host change gets +tested in the app. A dispatched run leaves every branch alone, because it +passes no `manifest_branch`. Neither job has a tag trigger, because a tag push +cannot use the `workflow_run` gate on green CI and would be an unverified path +to a registry. ### Notifying the consumers diff --git a/ios/truapi-host/README.md b/ios/truapi-host/README.md index 8d44b3c6e..fd25034cf 100644 --- a/ios/truapi-host/README.md +++ b/ios/truapi-host/README.md @@ -24,8 +24,22 @@ The generated bindings, the container bundle and the xcframework are all **gitig # "@parity/ios-host " GitHub release, # and point the root Package.swift at it # (URL + checksum) +./scripts/tag-release.sh + # commit the generated sources plus that + # manifest and tag it : the tag a + # SwiftPM consumer resolves ``` +A consumer pins the plain semver tag, not the `@parity/ios-host@` one, +which SwiftPM cannot see: + +```swift +.package(url: "https://github.com/paritytech/host-rust-core", exact: "0.12.0") +``` + +`release-ios.yml` runs all three in order and clones and compiles the tag +before pushing it. Run them by hand only as a fallback. + When only the bindings need refreshing — a Rust surface change with no container or xcframework impact — skip the full rebuild, which needs Xcode and the iOS targets: