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

updated for permission level on members struct #31

Merged
merged 1 commit into from
May 29, 2024
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
2 changes: 1 addition & 1 deletion LibXMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.platform = :ios, '13.0', :macos, '11.0'
s.swift_version = '5.3'

s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c86272d/LibXMTPSwiftFFI.zip", :type => :zip }
s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-bd8360b/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-c86272d/LibXMTPSwiftFFI.zip",
checksum: "c9a5fdc8ffc936f1f3901cb3cb3aedea06782a68d962ef498696fd7e4f888c48"
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-bd8360b/LibXMTPSwiftFFI.zip",
checksum: "90928c0849706499a8ec034c0bd19858b50edafa08c1ab22945656d6b002cd5e"
),
.testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]),
]
Expand Down
6 changes: 3 additions & 3 deletions Sources/LibXMTP/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: c86272d
Branch: HEAD
Date: 2024-05-28 21:11:59 +0000
Version: bd8360b
Branch: main
Date: 2024-05-29 16:47:55 +0000
61 changes: 59 additions & 2 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2160,13 +2160,15 @@ public struct FfiGroupMember {
public var inboxId: String
public var accountAddresses: [String]
public var installationIds: [Data]
public var permissionLevel: FfiPermissionLevel

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(inboxId: String, accountAddresses: [String], installationIds: [Data]) {
public init(inboxId: String, accountAddresses: [String], installationIds: [Data], permissionLevel: FfiPermissionLevel) {
self.inboxId = inboxId
self.accountAddresses = accountAddresses
self.installationIds = installationIds
self.permissionLevel = permissionLevel
}
}

Expand All @@ -2181,13 +2183,17 @@ extension FfiGroupMember: Equatable, Hashable {
if lhs.installationIds != rhs.installationIds {
return false
}
if lhs.permissionLevel != rhs.permissionLevel {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(inboxId)
hasher.combine(accountAddresses)
hasher.combine(installationIds)
hasher.combine(permissionLevel)
}
}

Expand All @@ -2197,14 +2203,16 @@ public struct FfiConverterTypeFfiGroupMember: FfiConverterRustBuffer {
try FfiGroupMember(
inboxId: FfiConverterString.read(from: &buf),
accountAddresses: FfiConverterSequenceString.read(from: &buf),
installationIds: FfiConverterSequenceData.read(from: &buf)
installationIds: FfiConverterSequenceData.read(from: &buf),
permissionLevel: FfiConverterTypeFfiPermissionLevel.read(from: &buf)
)
}

public static func write(_ value: FfiGroupMember, into buf: inout [UInt8]) {
FfiConverterString.write(value.inboxId, into: &buf)
FfiConverterSequenceString.write(value.accountAddresses, into: &buf)
FfiConverterSequenceData.write(value.installationIds, into: &buf)
FfiConverterTypeFfiPermissionLevel.write(value.permissionLevel, into: &buf)
}
}

Expand Down Expand Up @@ -2887,6 +2895,55 @@ extension FfiGroupMessageKind: 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 FfiPermissionLevel {
case member
case admin
case superAdmin
}

public struct FfiConverterTypeFfiPermissionLevel: FfiConverterRustBuffer {
typealias SwiftType = FfiPermissionLevel

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiPermissionLevel {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .member

case 2: return .admin

case 3: return .superAdmin

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: FfiPermissionLevel, into buf: inout [UInt8]) {
switch value {
case .member:
writeInt(&buf, Int32(1))

case .admin:
writeInt(&buf, Int32(2))

case .superAdmin:
writeInt(&buf, Int32(3))
}
}
}

public func FfiConverterTypeFfiPermissionLevel_lift(_ buf: RustBuffer) throws -> FfiPermissionLevel {
return try FfiConverterTypeFfiPermissionLevel.lift(buf)
}

public func FfiConverterTypeFfiPermissionLevel_lower(_ value: FfiPermissionLevel) -> RustBuffer {
return FfiConverterTypeFfiPermissionLevel.lower(value)
}

extension FfiPermissionLevel: 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 FfiSortDirection {
case unspecified
case ascending
Expand Down