Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issues #97

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LibXMTP.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/LibXMTP/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -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
120 changes: 68 additions & 52 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down