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

update bindings for content type filter #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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.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'
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-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
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-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"]),
]
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: 7d863bde
Version: a9111a13
Branch: main
Date: 2024-12-20 22:46:38 +0000
Date: 2024-12-21 00:25:32 +0000
161 changes: 159 additions & 2 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -4935,6 +4937,9 @@ extension FfiListMessagesOptions: Equatable, Hashable {
if lhs.direction != rhs.direction {
return false
}
if lhs.contentTypes != rhs.contentTypes {
return false
}
return true
}

Expand All @@ -4944,6 +4949,7 @@ extension FfiListMessagesOptions: Equatable, Hashable {
hasher.combine(limit)
hasher.combine(deliveryStatus)
hasher.combine(direction)
hasher.combine(contentTypes)
}
}

Expand All @@ -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)
)
}

Expand All @@ -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)
}
}

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