Skip to content

Commit

Permalink
Merge pull request #94 from xmtp/cv/12-20-update_bindings_for_content…
Browse files Browse the repository at this point in the history
…_type_filter

update bindings for content type filter
  • Loading branch information
cameronvoell authored Jan 2, 2025
2 parents 2fd0b26 + fe0f2b7 commit b687d09
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 8 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.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

0 comments on commit b687d09

Please sign in to comment.