From fe0f2b79a3c4e46fb15bc25b1401117481dc6ac7 Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Fri, 20 Dec 2024 17:29:35 -0800 Subject: [PATCH] update bindings for content type filter --- LibXMTP.podspec | 4 +- Package.swift | 4 +- Sources/LibXMTP/libxmtp-version.txt | 4 +- Sources/LibXMTP/xmtpv3.swift | 161 +++++++++++++++++++++++++++- 4 files changed, 165 insertions(+), 8 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index f53fe8a..950d21a 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '3.0.15' + s.version = '3.0.16' 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-7d863bd/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-a9111a1/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 2fda224..3093655 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-7d863bd/LibXMTPSwiftFFI.zip", - checksum: "0b496c3b016338b88d7b5b62828030b6107c0ee195bd869d0309507237a53bff" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-a9111a1/LibXMTPSwiftFFI.zip", + checksum: "f01d58427f5d097f4734e42e498102084ce3f9f64a310a3b6d62ee6b32b3a108" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index a374f73..58d1a96 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 7d863bde +Version: a9111a13 Branch: main -Date: 2024-12-20 22:46:38 +0000 +Date: 2024-12-21 00:25:32 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 7ab1134..436c055 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -4906,15 +4906,17 @@ public struct FfiListMessagesOptions { public var limit: Int64? public var deliveryStatus: FfiDeliveryStatus? public var direction: FfiDirection? + public var contentTypes: [FfiContentType]? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(sentBeforeNs: Int64?, sentAfterNs: Int64?, limit: Int64?, deliveryStatus: FfiDeliveryStatus?, direction: FfiDirection?) { + public init(sentBeforeNs: Int64?, sentAfterNs: Int64?, limit: Int64?, deliveryStatus: FfiDeliveryStatus?, direction: FfiDirection?, contentTypes: [FfiContentType]?) { self.sentBeforeNs = sentBeforeNs self.sentAfterNs = sentAfterNs self.limit = limit self.deliveryStatus = deliveryStatus self.direction = direction + self.contentTypes = contentTypes } } @@ -4935,6 +4937,9 @@ extension FfiListMessagesOptions: Equatable, Hashable { if lhs.direction != rhs.direction { return false } + if lhs.contentTypes != rhs.contentTypes { + return false + } return true } @@ -4944,6 +4949,7 @@ extension FfiListMessagesOptions: Equatable, Hashable { hasher.combine(limit) hasher.combine(deliveryStatus) hasher.combine(direction) + hasher.combine(contentTypes) } } @@ -4958,7 +4964,8 @@ public struct FfiConverterTypeFfiListMessagesOptions: FfiConverterRustBuffer { sentAfterNs: FfiConverterOptionInt64.read(from: &buf), limit: FfiConverterOptionInt64.read(from: &buf), deliveryStatus: FfiConverterOptionTypeFfiDeliveryStatus.read(from: &buf), - direction: FfiConverterOptionTypeFfiDirection.read(from: &buf) + direction: FfiConverterOptionTypeFfiDirection.read(from: &buf), + contentTypes: FfiConverterOptionSequenceTypeFfiContentType.read(from: &buf) ) } @@ -4968,6 +4975,7 @@ public struct FfiConverterTypeFfiListMessagesOptions: FfiConverterRustBuffer { FfiConverterOptionInt64.write(value.limit, into: &buf) FfiConverterOptionTypeFfiDeliveryStatus.write(value.deliveryStatus, into: &buf) FfiConverterOptionTypeFfiDirection.write(value.direction, into: &buf) + FfiConverterOptionSequenceTypeFfiContentType.write(value.contentTypes, into: &buf) } } @@ -5733,6 +5741,106 @@ extension FfiConsentState: Equatable, Hashable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum FfiContentType { + case unknown + case text + case groupMembershipChange + case groupUpdated + case reaction + case readReceipt + case reply + case attachment + case remoteAttachment + case transactionReference +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public struct FfiConverterTypeFfiContentType: FfiConverterRustBuffer { + typealias SwiftType = FfiContentType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiContentType { + let variant: Int32 = try readInt(&buf) + switch variant { + case 1: return .unknown + + case 2: return .text + + case 3: return .groupMembershipChange + + case 4: return .groupUpdated + + case 5: return .reaction + + case 6: return .readReceipt + + case 7: return .reply + + case 8: return .attachment + + case 9: return .remoteAttachment + + case 10: return .transactionReference + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: FfiContentType, into buf: inout [UInt8]) { + switch value { + case .unknown: + writeInt(&buf, Int32(1)) + + case .text: + writeInt(&buf, Int32(2)) + + case .groupMembershipChange: + writeInt(&buf, Int32(3)) + + case .groupUpdated: + writeInt(&buf, Int32(4)) + + case .reaction: + writeInt(&buf, Int32(5)) + + case .readReceipt: + writeInt(&buf, Int32(6)) + + case .reply: + writeInt(&buf, Int32(7)) + + case .attachment: + writeInt(&buf, Int32(8)) + + case .remoteAttachment: + writeInt(&buf, Int32(9)) + + case .transactionReference: + writeInt(&buf, Int32(10)) + } + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiContentType_lift(_ buf: RustBuffer) throws -> FfiContentType { + return try FfiConverterTypeFfiContentType.lift(buf) +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiContentType_lower(_ value: FfiContentType) -> RustBuffer { + return FfiConverterTypeFfiContentType.lower(value) +} + +extension FfiContentType: Equatable, Hashable {} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + public enum FfiConversationMessageKind { case application case membershipChange @@ -7124,6 +7232,30 @@ private struct FfiConverterOptionTypeFfiMetadataField: FfiConverterRustBuffer { } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterOptionSequenceTypeFfiContentType: FfiConverterRustBuffer { + typealias SwiftType = [FfiContentType]? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterSequenceTypeFfiContentType.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 FfiConverterSequenceTypeFfiContentType.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -7449,6 +7581,31 @@ private struct FfiConverterSequenceTypeFfiV2QueryResponse: FfiConverterRustBuffe } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterSequenceTypeFfiContentType: FfiConverterRustBuffer { + typealias SwiftType = [FfiContentType] + + public static func write(_ value: [FfiContentType], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeFfiContentType.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiContentType] { + let len: Int32 = try readInt(&buf) + var seq = [FfiContentType]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + try seq.append(FfiConverterTypeFfiContentType.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif