Skip to content

Commit

Permalink
Bump to version v1.1.69 (matrix-rust-sdk/main 8e0282ac4ae9e8f87073770…
Browse files Browse the repository at this point in the history
…ff02c9b8e13ba7b16)
  • Loading branch information
pixlwave committed Jul 8, 2024
1 parent 0031d98 commit 8cb0c20
Show file tree
Hide file tree
Showing 4 changed files with 1,812 additions and 1,478 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let checksum = "462ccb2de5c92405cf842885f1d44eed1b62723bbecc97b1bcc2af1ee5e18959"
let version = "v1.1.68"
let checksum = "5d3a37a716ac04d2991ee224e55bcacfb8ede66ef7e782175505ad5a096033b3"
let version = "v1.1.69"
let url = "https://github.com/matrix-org/matrix-rust-components-swift/releases/download/\(version)/MatrixSDKFFI.xcframework.zip"
let package = Package(
name: "MatrixRustSDK",
Expand Down
117 changes: 117 additions & 0 deletions Sources/MatrixRustSDK/matrix_sdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,120 @@ fileprivate struct FfiConverterString: FfiConverter {
}




/**
* The data needed to perform authorization using OpenID Connect.
*/
public protocol OidcAuthorizationDataProtocol : AnyObject {

/**
* The login URL to use for authorization.
*/
func loginUrl() -> String

}

/**
* The data needed to perform authorization using OpenID Connect.
*/
open class OidcAuthorizationData:
OidcAuthorizationDataProtocol {
fileprivate let pointer: UnsafeMutableRawPointer!

/// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
public struct NoPointer {
public init() {}
}

// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
self.pointer = pointer
}

/// This constructor can be used to instantiate a fake object.
/// - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
///
/// - Warning:
/// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
public init(noPointer: NoPointer) {
self.pointer = nil
}

public func uniffiClonePointer() -> UnsafeMutableRawPointer {
return try! rustCall { uniffi_matrix_sdk_fn_clone_oidcauthorizationdata(self.pointer, $0) }
}
// No primary constructor declared for this class.

deinit {
guard let pointer = pointer else {
return
}

try! rustCall { uniffi_matrix_sdk_fn_free_oidcauthorizationdata(pointer, $0) }
}




/**
* The login URL to use for authorization.
*/
open func loginUrl() -> String {
return try! FfiConverterString.lift(try! rustCall() {
uniffi_matrix_sdk_fn_method_oidcauthorizationdata_login_url(self.uniffiClonePointer(),$0
)
})
}


}

public struct FfiConverterTypeOidcAuthorizationData: FfiConverter {

typealias FfiType = UnsafeMutableRawPointer
typealias SwiftType = OidcAuthorizationData

public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> OidcAuthorizationData {
return OidcAuthorizationData(unsafeFromRawPointer: pointer)
}

public static func lower(_ value: OidcAuthorizationData) -> UnsafeMutableRawPointer {
return value.uniffiClonePointer()
}

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OidcAuthorizationData {
let v: UInt64 = try readInt(&buf)
// The Rust code won't compile if a pointer won't fit in a UInt64.
// We have to go via `UInt` because that's the thing that's the size of a pointer.
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
if (ptr == nil) {
throw UniffiInternalError.unexpectedNullPointer
}
return try lift(ptr!)
}

public static func write(_ value: OidcAuthorizationData, into buf: inout [UInt8]) {
// This fiddling is because `Int` is the thing that's the same size as a pointer.
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
}
}




public func FfiConverterTypeOidcAuthorizationData_lift(_ pointer: UnsafeMutableRawPointer) throws -> OidcAuthorizationData {
return try FfiConverterTypeOidcAuthorizationData.lift(pointer)
}

public func FfiConverterTypeOidcAuthorizationData_lower(_ value: OidcAuthorizationData) -> UnsafeMutableRawPointer {
return FfiConverterTypeOidcAuthorizationData.lower(value)
}


/**
* A set of common power levels required for various operations within a room,
* that can be applied as a single operation. When updating these
Expand Down Expand Up @@ -1037,6 +1151,9 @@ private var initializationResult: InitializationResult {
if bindings_contract_version != scaffolding_contract_version {
return InitializationResult.contractVersionMismatch
}
if (uniffi_matrix_sdk_checksum_method_oidcauthorizationdata_login_url() != 59213) {
return InitializationResult.apiChecksumMismatch
}

return InitializationResult.ok
}
Expand Down
195 changes: 0 additions & 195 deletions Sources/MatrixRustSDK/matrix_sdk_base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,201 +419,6 @@ fileprivate struct FfiConverterString: FfiConverter {
}
}


/**
* Current draft of the composer for the room.
*/
public struct ComposerDraft {
/**
* The draft content in plain text.
*/
public var plainText: String
/**
* If the message is formatted in HTML, the HTML representation of the
* message.
*/
public var htmlText: String?
/**
* The type of draft.
*/
public var draftType: ComposerDraftType

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The draft content in plain text.
*/plainText: String,
/**
* If the message is formatted in HTML, the HTML representation of the
* message.
*/htmlText: String?,
/**
* The type of draft.
*/draftType: ComposerDraftType) {
self.plainText = plainText
self.htmlText = htmlText
self.draftType = draftType
}
}



extension ComposerDraft: Equatable, Hashable {
public static func ==(lhs: ComposerDraft, rhs: ComposerDraft) -> Bool {
if lhs.plainText != rhs.plainText {
return false
}
if lhs.htmlText != rhs.htmlText {
return false
}
if lhs.draftType != rhs.draftType {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(plainText)
hasher.combine(htmlText)
hasher.combine(draftType)
}
}


public struct FfiConverterTypeComposerDraft: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposerDraft {
return
try ComposerDraft(
plainText: FfiConverterString.read(from: &buf),
htmlText: FfiConverterOptionString.read(from: &buf),
draftType: FfiConverterTypeComposerDraftType.read(from: &buf)
)
}

public static func write(_ value: ComposerDraft, into buf: inout [UInt8]) {
FfiConverterString.write(value.plainText, into: &buf)
FfiConverterOptionString.write(value.htmlText, into: &buf)
FfiConverterTypeComposerDraftType.write(value.draftType, into: &buf)
}
}


public func FfiConverterTypeComposerDraft_lift(_ buf: RustBuffer) throws -> ComposerDraft {
return try FfiConverterTypeComposerDraft.lift(buf)
}

public func FfiConverterTypeComposerDraft_lower(_ value: ComposerDraft) -> RustBuffer {
return FfiConverterTypeComposerDraft.lower(value)
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
* The type of draft of the composer.
*/

public enum ComposerDraftType {

/**
* The draft is a new message.
*/
case newMessage
/**
* The draft is a reply to an event.
*/
case reply(
/**
* The ID of the event being replied to.
*/eventId: String
)
/**
* The draft is an edit of an event.
*/
case edit(
/**
* The ID of the event being edited.
*/eventId: String
)
}


public struct FfiConverterTypeComposerDraftType: FfiConverterRustBuffer {
typealias SwiftType = ComposerDraftType

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

case 1: return .newMessage

case 2: return .reply(eventId: try FfiConverterString.read(from: &buf)
)

case 3: return .edit(eventId: try FfiConverterString.read(from: &buf)
)

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: ComposerDraftType, into buf: inout [UInt8]) {
switch value {


case .newMessage:
writeInt(&buf, Int32(1))


case let .reply(eventId):
writeInt(&buf, Int32(2))
FfiConverterString.write(eventId, into: &buf)


case let .edit(eventId):
writeInt(&buf, Int32(3))
FfiConverterString.write(eventId, into: &buf)

}
}
}


public func FfiConverterTypeComposerDraftType_lift(_ buf: RustBuffer) throws -> ComposerDraftType {
return try FfiConverterTypeComposerDraftType.lift(buf)
}

public func FfiConverterTypeComposerDraftType_lower(_ value: ComposerDraftType) -> RustBuffer {
return FfiConverterTypeComposerDraftType.lower(value)
}



extension ComposerDraftType: Equatable, Hashable {}



fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
typealias SwiftType = String?

public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterString.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 FfiConverterString.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}

private enum InitializationResult {
case ok
case contractVersionMismatch
Expand Down
Loading

0 comments on commit 8cb0c20

Please sign in to comment.