Skip to content

Commit 8cb0c20

Browse files
committed
Bump to version v1.1.69 (matrix-rust-sdk/main 8e0282ac4ae9e8f87073770ff02c9b8e13ba7b16)
1 parent 0031d98 commit 8cb0c20

File tree

4 files changed

+1812
-1478
lines changed

4 files changed

+1812
-1478
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// swift-tools-version:5.5
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
import PackageDescription
4-
let checksum = "462ccb2de5c92405cf842885f1d44eed1b62723bbecc97b1bcc2af1ee5e18959"
5-
let version = "v1.1.68"
4+
let checksum = "5d3a37a716ac04d2991ee224e55bcacfb8ede66ef7e782175505ad5a096033b3"
5+
let version = "v1.1.69"
66
let url = "https://github.com/matrix-org/matrix-rust-components-swift/releases/download/\(version)/MatrixSDKFFI.xcframework.zip"
77
let package = Package(
88
name: "MatrixRustSDK",

Sources/MatrixRustSDK/matrix_sdk.swift

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,120 @@ fileprivate struct FfiConverterString: FfiConverter {
433433
}
434434

435435

436+
437+
438+
/**
439+
* The data needed to perform authorization using OpenID Connect.
440+
*/
441+
public protocol OidcAuthorizationDataProtocol : AnyObject {
442+
443+
/**
444+
* The login URL to use for authorization.
445+
*/
446+
func loginUrl() -> String
447+
448+
}
449+
450+
/**
451+
* The data needed to perform authorization using OpenID Connect.
452+
*/
453+
open class OidcAuthorizationData:
454+
OidcAuthorizationDataProtocol {
455+
fileprivate let pointer: UnsafeMutableRawPointer!
456+
457+
/// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
458+
public struct NoPointer {
459+
public init() {}
460+
}
461+
462+
// TODO: We'd like this to be `private` but for Swifty reasons,
463+
// we can't implement `FfiConverter` without making this `required` and we can't
464+
// make it `required` without making it `public`.
465+
required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
466+
self.pointer = pointer
467+
}
468+
469+
/// This constructor can be used to instantiate a fake object.
470+
/// - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
471+
///
472+
/// - Warning:
473+
/// 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.
474+
public init(noPointer: NoPointer) {
475+
self.pointer = nil
476+
}
477+
478+
public func uniffiClonePointer() -> UnsafeMutableRawPointer {
479+
return try! rustCall { uniffi_matrix_sdk_fn_clone_oidcauthorizationdata(self.pointer, $0) }
480+
}
481+
// No primary constructor declared for this class.
482+
483+
deinit {
484+
guard let pointer = pointer else {
485+
return
486+
}
487+
488+
try! rustCall { uniffi_matrix_sdk_fn_free_oidcauthorizationdata(pointer, $0) }
489+
}
490+
491+
492+
493+
494+
/**
495+
* The login URL to use for authorization.
496+
*/
497+
open func loginUrl() -> String {
498+
return try! FfiConverterString.lift(try! rustCall() {
499+
uniffi_matrix_sdk_fn_method_oidcauthorizationdata_login_url(self.uniffiClonePointer(),$0
500+
)
501+
})
502+
}
503+
504+
505+
}
506+
507+
public struct FfiConverterTypeOidcAuthorizationData: FfiConverter {
508+
509+
typealias FfiType = UnsafeMutableRawPointer
510+
typealias SwiftType = OidcAuthorizationData
511+
512+
public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> OidcAuthorizationData {
513+
return OidcAuthorizationData(unsafeFromRawPointer: pointer)
514+
}
515+
516+
public static func lower(_ value: OidcAuthorizationData) -> UnsafeMutableRawPointer {
517+
return value.uniffiClonePointer()
518+
}
519+
520+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OidcAuthorizationData {
521+
let v: UInt64 = try readInt(&buf)
522+
// The Rust code won't compile if a pointer won't fit in a UInt64.
523+
// We have to go via `UInt` because that's the thing that's the size of a pointer.
524+
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
525+
if (ptr == nil) {
526+
throw UniffiInternalError.unexpectedNullPointer
527+
}
528+
return try lift(ptr!)
529+
}
530+
531+
public static func write(_ value: OidcAuthorizationData, into buf: inout [UInt8]) {
532+
// This fiddling is because `Int` is the thing that's the same size as a pointer.
533+
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
534+
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
535+
}
536+
}
537+
538+
539+
540+
541+
public func FfiConverterTypeOidcAuthorizationData_lift(_ pointer: UnsafeMutableRawPointer) throws -> OidcAuthorizationData {
542+
return try FfiConverterTypeOidcAuthorizationData.lift(pointer)
543+
}
544+
545+
public func FfiConverterTypeOidcAuthorizationData_lower(_ value: OidcAuthorizationData) -> UnsafeMutableRawPointer {
546+
return FfiConverterTypeOidcAuthorizationData.lower(value)
547+
}
548+
549+
436550
/**
437551
* A set of common power levels required for various operations within a room,
438552
* that can be applied as a single operation. When updating these
@@ -1037,6 +1151,9 @@ private var initializationResult: InitializationResult {
10371151
if bindings_contract_version != scaffolding_contract_version {
10381152
return InitializationResult.contractVersionMismatch
10391153
}
1154+
if (uniffi_matrix_sdk_checksum_method_oidcauthorizationdata_login_url() != 59213) {
1155+
return InitializationResult.apiChecksumMismatch
1156+
}
10401157

10411158
return InitializationResult.ok
10421159
}

Sources/MatrixRustSDK/matrix_sdk_base.swift

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -419,201 +419,6 @@ fileprivate struct FfiConverterString: FfiConverter {
419419
}
420420
}
421421

422-
423-
/**
424-
* Current draft of the composer for the room.
425-
*/
426-
public struct ComposerDraft {
427-
/**
428-
* The draft content in plain text.
429-
*/
430-
public var plainText: String
431-
/**
432-
* If the message is formatted in HTML, the HTML representation of the
433-
* message.
434-
*/
435-
public var htmlText: String?
436-
/**
437-
* The type of draft.
438-
*/
439-
public var draftType: ComposerDraftType
440-
441-
// Default memberwise initializers are never public by default, so we
442-
// declare one manually.
443-
public init(
444-
/**
445-
* The draft content in plain text.
446-
*/plainText: String,
447-
/**
448-
* If the message is formatted in HTML, the HTML representation of the
449-
* message.
450-
*/htmlText: String?,
451-
/**
452-
* The type of draft.
453-
*/draftType: ComposerDraftType) {
454-
self.plainText = plainText
455-
self.htmlText = htmlText
456-
self.draftType = draftType
457-
}
458-
}
459-
460-
461-
462-
extension ComposerDraft: Equatable, Hashable {
463-
public static func ==(lhs: ComposerDraft, rhs: ComposerDraft) -> Bool {
464-
if lhs.plainText != rhs.plainText {
465-
return false
466-
}
467-
if lhs.htmlText != rhs.htmlText {
468-
return false
469-
}
470-
if lhs.draftType != rhs.draftType {
471-
return false
472-
}
473-
return true
474-
}
475-
476-
public func hash(into hasher: inout Hasher) {
477-
hasher.combine(plainText)
478-
hasher.combine(htmlText)
479-
hasher.combine(draftType)
480-
}
481-
}
482-
483-
484-
public struct FfiConverterTypeComposerDraft: FfiConverterRustBuffer {
485-
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposerDraft {
486-
return
487-
try ComposerDraft(
488-
plainText: FfiConverterString.read(from: &buf),
489-
htmlText: FfiConverterOptionString.read(from: &buf),
490-
draftType: FfiConverterTypeComposerDraftType.read(from: &buf)
491-
)
492-
}
493-
494-
public static func write(_ value: ComposerDraft, into buf: inout [UInt8]) {
495-
FfiConverterString.write(value.plainText, into: &buf)
496-
FfiConverterOptionString.write(value.htmlText, into: &buf)
497-
FfiConverterTypeComposerDraftType.write(value.draftType, into: &buf)
498-
}
499-
}
500-
501-
502-
public func FfiConverterTypeComposerDraft_lift(_ buf: RustBuffer) throws -> ComposerDraft {
503-
return try FfiConverterTypeComposerDraft.lift(buf)
504-
}
505-
506-
public func FfiConverterTypeComposerDraft_lower(_ value: ComposerDraft) -> RustBuffer {
507-
return FfiConverterTypeComposerDraft.lower(value)
508-
}
509-
510-
// Note that we don't yet support `indirect` for enums.
511-
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
512-
/**
513-
* The type of draft of the composer.
514-
*/
515-
516-
public enum ComposerDraftType {
517-
518-
/**
519-
* The draft is a new message.
520-
*/
521-
case newMessage
522-
/**
523-
* The draft is a reply to an event.
524-
*/
525-
case reply(
526-
/**
527-
* The ID of the event being replied to.
528-
*/eventId: String
529-
)
530-
/**
531-
* The draft is an edit of an event.
532-
*/
533-
case edit(
534-
/**
535-
* The ID of the event being edited.
536-
*/eventId: String
537-
)
538-
}
539-
540-
541-
public struct FfiConverterTypeComposerDraftType: FfiConverterRustBuffer {
542-
typealias SwiftType = ComposerDraftType
543-
544-
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposerDraftType {
545-
let variant: Int32 = try readInt(&buf)
546-
switch variant {
547-
548-
case 1: return .newMessage
549-
550-
case 2: return .reply(eventId: try FfiConverterString.read(from: &buf)
551-
)
552-
553-
case 3: return .edit(eventId: try FfiConverterString.read(from: &buf)
554-
)
555-
556-
default: throw UniffiInternalError.unexpectedEnumCase
557-
}
558-
}
559-
560-
public static func write(_ value: ComposerDraftType, into buf: inout [UInt8]) {
561-
switch value {
562-
563-
564-
case .newMessage:
565-
writeInt(&buf, Int32(1))
566-
567-
568-
case let .reply(eventId):
569-
writeInt(&buf, Int32(2))
570-
FfiConverterString.write(eventId, into: &buf)
571-
572-
573-
case let .edit(eventId):
574-
writeInt(&buf, Int32(3))
575-
FfiConverterString.write(eventId, into: &buf)
576-
577-
}
578-
}
579-
}
580-
581-
582-
public func FfiConverterTypeComposerDraftType_lift(_ buf: RustBuffer) throws -> ComposerDraftType {
583-
return try FfiConverterTypeComposerDraftType.lift(buf)
584-
}
585-
586-
public func FfiConverterTypeComposerDraftType_lower(_ value: ComposerDraftType) -> RustBuffer {
587-
return FfiConverterTypeComposerDraftType.lower(value)
588-
}
589-
590-
591-
592-
extension ComposerDraftType: Equatable, Hashable {}
593-
594-
595-
596-
fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
597-
typealias SwiftType = String?
598-
599-
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
600-
guard let value = value else {
601-
writeInt(&buf, Int8(0))
602-
return
603-
}
604-
writeInt(&buf, Int8(1))
605-
FfiConverterString.write(value, into: &buf)
606-
}
607-
608-
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
609-
switch try readInt(&buf) as Int8 {
610-
case 0: return nil
611-
case 1: return try FfiConverterString.read(from: &buf)
612-
default: throw UniffiInternalError.unexpectedOptionalTag
613-
}
614-
}
615-
}
616-
617422
private enum InitializationResult {
618423
case ok
619424
case contractVersionMismatch

0 commit comments

Comments
 (0)