From 62afc4589ce83224f575bb959c1fd386de81a5f0 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 6 Jan 2025 16:42:58 -0800 Subject: [PATCH] bump the bindings again --- LibXMTP.podspec | 4 +- Package.swift | 4 +- Sources/LibXMTP/libxmtp-version.txt | 4 +- Sources/LibXMTP/xmtpv3.swift | 120 ++++++++++++++++------------ 4 files changed, 74 insertions(+), 58 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index edc1981..5db3de9 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '3.0.17' + s.version = '3.0.18' s.summary = 'XMTP shared Rust code that powers cross-platform SDKs' s.homepage = 'https://github.com/xmtp/libxmtp-swift' @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.platform = :ios, '14.0', :macos, '11.0' s.swift_version = '5.3' - s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-821c912/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-ab9bb05/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 7c9e8d8..fb96699 100644 --- a/Package.swift +++ b/Package.swift @@ -27,8 +27,8 @@ let package = Package( ), .binaryTarget( name: "LibXMTPSwiftFFI", - url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-821c912/LibXMTPSwiftFFI.zip", - checksum: "ce6e995457ff3581913856ebd6e668f958b265bf2aff11d098f0f9bec3a8ff13" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-ab9bb05/LibXMTPSwiftFFI.zip", + checksum: "09ddcba339a49a9e7b01269c504c487cfb896155974a0c3daccd14e95e4a0df6" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index cc7b5f9..8458e4d 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 821c9123 +Version: ab9bb055 Branch: main -Date: 2025-01-06 16:35:49 +0000 +Date: 2025-01-07 00:08:33 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index c505057..f79fc7e 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -1581,7 +1581,11 @@ public func FfiConverterTypeFfiConversationCallback_lower(_ value: FfiConversati return FfiConverterTypeFfiConversationCallback.lower(value) } -public protocol FfiConversationListItemProtocol: AnyObject {} +public protocol FfiConversationListItemProtocol: AnyObject { + func conversation() -> FfiConversation + + func lastMessage() -> FfiMessage? +} open class FfiConversationListItem: FfiConversationListItemProtocol @@ -1631,6 +1635,18 @@ open class FfiConversationListItem: try! rustCall { uniffi_xmtpv3_fn_free_fficonversationlistitem(pointer, $0) } } + + open func conversation() -> FfiConversation { + return try! FfiConverterTypeFfiConversation.lift(try! rustCall { + uniffi_xmtpv3_fn_method_fficonversationlistitem_conversation(self.uniffiClonePointer(), $0) + }) + } + + open func lastMessage() -> FfiMessage? { + return try! FfiConverterOptionTypeFfiMessage.lift(try! rustCall { + uniffi_xmtpv3_fn_method_fficonversationlistitem_last_message(self.uniffiClonePointer(), $0) + }) + } } #if swift(>=5.8) @@ -1804,11 +1820,11 @@ public protocol FfiConversationsProtocol: AnyObject { func getSyncGroup() throws -> FfiConversation - func list(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] + func list(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] - func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] + func listDms(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] - func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] + func listGroups(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] func processStreamedWelcomeMessage(envelopeBytes: Data) async throws -> FfiConversation @@ -1938,55 +1954,25 @@ open class FfiConversations: }) } - open func list(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_xmtpv3_fn_method_fficonversations_list( - self.uniffiClonePointer(), - FfiConverterTypeFfiListConversationsOptions.lower(opts) - ) - }, - pollFunc: ffi_xmtpv3_rust_future_poll_rust_buffer, - completeFunc: ffi_xmtpv3_rust_future_complete_rust_buffer, - freeFunc: ffi_xmtpv3_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift, - errorHandler: FfiConverterTypeGenericError.lift - ) + open func list(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] { + return try FfiConverterSequenceTypeFfiConversationListItem.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_fficonversations_list(self.uniffiClonePointer(), + FfiConverterTypeFfiListConversationsOptions.lower(opts), $0) + }) } - open func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_xmtpv3_fn_method_fficonversations_list_dms( - self.uniffiClonePointer(), - FfiConverterTypeFfiListConversationsOptions.lower(opts) - ) - }, - pollFunc: ffi_xmtpv3_rust_future_poll_rust_buffer, - completeFunc: ffi_xmtpv3_rust_future_complete_rust_buffer, - freeFunc: ffi_xmtpv3_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift, - errorHandler: FfiConverterTypeGenericError.lift - ) + open func listDms(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] { + return try FfiConverterSequenceTypeFfiConversationListItem.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_fficonversations_list_dms(self.uniffiClonePointer(), + FfiConverterTypeFfiListConversationsOptions.lower(opts), $0) + }) } - open func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_xmtpv3_fn_method_fficonversations_list_groups( - self.uniffiClonePointer(), - FfiConverterTypeFfiListConversationsOptions.lower(opts) - ) - }, - pollFunc: ffi_xmtpv3_rust_future_poll_rust_buffer, - completeFunc: ffi_xmtpv3_rust_future_complete_rust_buffer, - freeFunc: ffi_xmtpv3_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift, - errorHandler: FfiConverterTypeGenericError.lift - ) + open func listGroups(opts: FfiListConversationsOptions) throws -> [FfiConversationListItem] { + return try FfiConverterSequenceTypeFfiConversationListItem.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_fficonversations_list_groups(self.uniffiClonePointer(), + FfiConverterTypeFfiListConversationsOptions.lower(opts), $0) + }) } open func processStreamedWelcomeMessage(envelopeBytes: Data) async throws -> FfiConversation { @@ -7055,6 +7041,30 @@ private struct FfiConverterOptionTypeFfiCursor: FfiConverterRustBuffer { } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterOptionTypeFfiMessage: FfiConverterRustBuffer { + typealias SwiftType = FfiMessage? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeFfiMessage.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 FfiConverterTypeFfiMessage.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -8108,6 +8118,12 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_fficonversationcallback_on_error() != 461 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_fficonversationlistitem_conversation() != 20525 { + return InitializationResult.apiChecksumMismatch + } + if uniffi_xmtpv3_checksum_method_fficonversationlistitem_last_message() != 42510 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_fficonversationmetadata_conversation_type() != 22241 { return InitializationResult.apiChecksumMismatch } @@ -8126,13 +8142,13 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_fficonversations_get_sync_group() != 42973 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_fficonversations_list() != 32264 { + if uniffi_xmtpv3_checksum_method_fficonversations_list() != 23197 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_fficonversations_list_dms() != 59074 { + if uniffi_xmtpv3_checksum_method_fficonversations_list_dms() != 39437 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_fficonversations_list_groups() != 55611 { + if uniffi_xmtpv3_checksum_method_fficonversations_list_groups() != 7791 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_fficonversations_process_streamed_welcome_message() != 57376 {