Skip to content

Commit

Permalink
Merge pull request #96 from xmtp/np/conversation-list-performance
Browse files Browse the repository at this point in the history
Bindings for Conversation list performance
  • Loading branch information
nplasterer authored Jan 6, 2025
2 parents b687d09 + 7a11dde commit d6824ba
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 65 deletions.
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.16'
s.version = '3.0.17'
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-a9111a1/LibXMTPSwiftFFI.zip", :type => :zip }
s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-821c912/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-a9111a1/LibXMTPSwiftFFI.zip",
checksum: "f01d58427f5d097f4734e42e498102084ce3f9f64a310a3b6d62ee6b32b3a108"
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-821c912/LibXMTPSwiftFFI.zip",
checksum: "ce6e995457ff3581913856ebd6e668f958b265bf2aff11d098f0f9bec3a8ff13"
),
.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: a9111a13
Version: 821c9123
Branch: main
Date: 2024-12-21 00:25:32 +0000
Date: 2025-01-06 16:35:49 +0000
108 changes: 49 additions & 59 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1804,13 +1804,11 @@ public protocol FfiConversationsProtocol: AnyObject {

func getSyncGroup() throws -> FfiConversation

func list(opts: FfiListConversationsOptions) async throws -> [FfiConversation]
func list(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem]

func listConversations() async throws -> [FfiConversationListItem]
func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem]

func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversation]

func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversation]
func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem]

func processStreamedWelcomeMessage(envelopeBytes: Data) async throws -> FfiConversation

Expand Down Expand Up @@ -1940,7 +1938,7 @@ open class FfiConversations:
})
}

open func list(opts: FfiListConversationsOptions) async throws -> [FfiConversation] {
open func list(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
Expand All @@ -1952,28 +1950,12 @@ open class FfiConversations:
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: FfiConverterSequenceTypeFfiConversation.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func listConversations() async throws -> [FfiConversationListItem] {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_fficonversations_list_conversations(
self.uniffiClonePointer()
)
},
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) async throws -> [FfiConversation] {
open func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
Expand All @@ -1985,12 +1967,12 @@ open class FfiConversations:
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: FfiConverterSequenceTypeFfiConversation.lift,
liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversation] {
open func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversationListItem] {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
Expand All @@ -2002,7 +1984,7 @@ open class FfiConversations:
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: FfiConverterSequenceTypeFfiConversation.lift,
liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}
Expand Down Expand Up @@ -3704,6 +3686,11 @@ public protocol FfiXmtpClientProtocol: AnyObject {
*/
func revokeAllOtherInstallations() async throws -> FfiSignatureRequest

/**
* * Revoke a list of installations
*/
func revokeInstallations(installationIds: [Data]) async throws -> FfiSignatureRequest

/**
* Revokes or removes an identity - really a wallet address - from the existing client
*/
Expand Down Expand Up @@ -4018,6 +4005,26 @@ open class FfiXmtpClient:
)
}

/**
* * Revoke a list of installations
*/
open func revokeInstallations(installationIds: [Data]) async throws -> FfiSignatureRequest {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffixmtpclient_revoke_installations(
self.uniffiClonePointer(),
FfiConverterSequenceData.lower(installationIds)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_pointer,
completeFunc: ffi_xmtpv3_rust_future_complete_pointer,
freeFunc: ffi_xmtpv3_rust_future_free_pointer,
liftFunc: FfiConverterTypeFfiSignatureRequest.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}

/**
* Revokes or removes an identity - really a wallet address - from the existing client
*/
Expand Down Expand Up @@ -4828,14 +4835,16 @@ public struct FfiListConversationsOptions {
public var createdBeforeNs: Int64?
public var limit: Int64?
public var consentState: FfiConsentState?
public var includeDuplicateDms: Bool

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(createdAfterNs: Int64?, createdBeforeNs: Int64?, limit: Int64?, consentState: FfiConsentState?) {
public init(createdAfterNs: Int64?, createdBeforeNs: Int64?, limit: Int64?, consentState: FfiConsentState?, includeDuplicateDms: Bool) {
self.createdAfterNs = createdAfterNs
self.createdBeforeNs = createdBeforeNs
self.limit = limit
self.consentState = consentState
self.includeDuplicateDms = includeDuplicateDms
}
}

Expand All @@ -4853,6 +4862,9 @@ extension FfiListConversationsOptions: Equatable, Hashable {
if lhs.consentState != rhs.consentState {
return false
}
if lhs.includeDuplicateDms != rhs.includeDuplicateDms {
return false
}
return true
}

Expand All @@ -4861,6 +4873,7 @@ extension FfiListConversationsOptions: Equatable, Hashable {
hasher.combine(createdBeforeNs)
hasher.combine(limit)
hasher.combine(consentState)
hasher.combine(includeDuplicateDms)
}
}

Expand All @@ -4874,7 +4887,8 @@ public struct FfiConverterTypeFfiListConversationsOptions: FfiConverterRustBuffe
createdAfterNs: FfiConverterOptionInt64.read(from: &buf),
createdBeforeNs: FfiConverterOptionInt64.read(from: &buf),
limit: FfiConverterOptionInt64.read(from: &buf),
consentState: FfiConverterOptionTypeFfiConsentState.read(from: &buf)
consentState: FfiConverterOptionTypeFfiConsentState.read(from: &buf),
includeDuplicateDms: FfiConverterBool.read(from: &buf)
)
}

Expand All @@ -4883,6 +4897,7 @@ public struct FfiConverterTypeFfiListConversationsOptions: FfiConverterRustBuffe
FfiConverterOptionInt64.write(value.createdBeforeNs, into: &buf)
FfiConverterOptionInt64.write(value.limit, into: &buf)
FfiConverterOptionTypeFfiConsentState.write(value.consentState, into: &buf)
FfiConverterBool.write(value.includeDuplicateDms, into: &buf)
}
}

Expand Down Expand Up @@ -7306,31 +7321,6 @@ private struct FfiConverterSequenceData: FfiConverterRustBuffer {
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
private struct FfiConverterSequenceTypeFfiConversation: FfiConverterRustBuffer {
typealias SwiftType = [FfiConversation]

public static func write(_ value: [FfiConversation], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeFfiConversation.write(item, into: &buf)
}
}

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiConversation] {
let len: Int32 = try readInt(&buf)
var seq = [FfiConversation]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
try seq.append(FfiConverterTypeFfiConversation.read(from: &buf))
}
return seq
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -8136,16 +8126,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() != 42790 {
if uniffi_xmtpv3_checksum_method_fficonversations_list() != 32264 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_list_conversations() != 29098 {
if uniffi_xmtpv3_checksum_method_fficonversations_list_dms() != 59074 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_list_dms() != 41576 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_list_groups() != 2386 {
if uniffi_xmtpv3_checksum_method_fficonversations_list_groups() != 55611 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_process_streamed_welcome_message() != 57376 {
Expand Down Expand Up @@ -8313,6 +8300,9 @@ private var initializationResult: InitializationResult = {
if uniffi_xmtpv3_checksum_method_ffixmtpclient_revoke_all_other_installations() != 36450 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_revoke_installations() != 2611 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_revoke_wallet() != 12211 {
return InitializationResult.apiChecksumMismatch
}
Expand Down

0 comments on commit d6824ba

Please sign in to comment.