@@ -4846,6 +4846,157 @@ public func FfiConverterTypeLazyTimelineItemProvider_lower(_ value: LazyTimeline
48464846
48474847
48484848
4849+ /**
4850+ * The `LeaveSpaceHandle` processes rooms to be left in the order they were
4851+ * provided by the [`SpaceService`] and annotates them with extra data to
4852+ * inform the leave process e.g. if the current user is the last room admin.
4853+ *
4854+ * Once the upstream client decides what rooms should actually be left, the
4855+ * handle provides a method to execute that too.
4856+ */
4857+ public protocol LeaveSpaceHandleProtocol : AnyObject {
4858+
4859+ /**
4860+ * Bulk leave the given rooms. Stops when encountering an error.
4861+ */
4862+ func leave(roomIds: [String]) async throws
4863+
4864+ /**
4865+ * A list of rooms to be left which next to normal [`SpaceRoom`] data also
4866+ * include leave specific information.
4867+ */
4868+ func rooms() -> [LeaveSpaceRoom]
4869+
4870+ }
4871+
4872+ /**
4873+ * The `LeaveSpaceHandle` processes rooms to be left in the order they were
4874+ * provided by the [`SpaceService`] and annotates them with extra data to
4875+ * inform the leave process e.g. if the current user is the last room admin.
4876+ *
4877+ * Once the upstream client decides what rooms should actually be left, the
4878+ * handle provides a method to execute that too.
4879+ */
4880+ open class LeaveSpaceHandle:
4881+ LeaveSpaceHandleProtocol {
4882+ fileprivate let pointer: UnsafeMutableRawPointer!
4883+
4884+ /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
4885+ public struct NoPointer {
4886+ public init() {}
4887+ }
4888+
4889+ // TODO: We'd like this to be `private` but for Swifty reasons,
4890+ // we can't implement `FfiConverter` without making this `required` and we can't
4891+ // make it `required` without making it `public`.
4892+ required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
4893+ self.pointer = pointer
4894+ }
4895+
4896+ /// This constructor can be used to instantiate a fake object.
4897+ /// - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
4898+ ///
4899+ /// - Warning:
4900+ /// 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.
4901+ public init(noPointer: NoPointer) {
4902+ self.pointer = nil
4903+ }
4904+
4905+ public func uniffiClonePointer() -> UnsafeMutableRawPointer {
4906+ return try! rustCall { uniffi_matrix_sdk_ffi_fn_clone_leavespacehandle(self.pointer, $0) }
4907+ }
4908+ // No primary constructor declared for this class.
4909+
4910+ deinit {
4911+ guard let pointer = pointer else {
4912+ return
4913+ }
4914+
4915+ try! rustCall { uniffi_matrix_sdk_ffi_fn_free_leavespacehandle(pointer, $0) }
4916+ }
4917+
4918+
4919+
4920+
4921+ /**
4922+ * Bulk leave the given rooms. Stops when encountering an error.
4923+ */
4924+ open func leave(roomIds: [String])async throws {
4925+ return
4926+ try await uniffiRustCallAsync(
4927+ rustFutureFunc: {
4928+ uniffi_matrix_sdk_ffi_fn_method_leavespacehandle_leave(
4929+ self.uniffiClonePointer(),
4930+ FfiConverterSequenceString.lower(roomIds)
4931+ )
4932+ },
4933+ pollFunc: ffi_matrix_sdk_ffi_rust_future_poll_void,
4934+ completeFunc: ffi_matrix_sdk_ffi_rust_future_complete_void,
4935+ freeFunc: ffi_matrix_sdk_ffi_rust_future_free_void,
4936+ liftFunc: { $0 },
4937+ errorHandler: FfiConverterTypeClientError.lift
4938+ )
4939+ }
4940+
4941+ /**
4942+ * A list of rooms to be left which next to normal [`SpaceRoom`] data also
4943+ * include leave specific information.
4944+ */
4945+ open func rooms() -> [LeaveSpaceRoom] {
4946+ return try! FfiConverterSequenceTypeLeaveSpaceRoom.lift(try! rustCall() {
4947+ uniffi_matrix_sdk_ffi_fn_method_leavespacehandle_rooms(self.uniffiClonePointer(),$0
4948+ )
4949+ })
4950+ }
4951+
4952+
4953+ }
4954+
4955+ public struct FfiConverterTypeLeaveSpaceHandle: FfiConverter {
4956+
4957+ typealias FfiType = UnsafeMutableRawPointer
4958+ typealias SwiftType = LeaveSpaceHandle
4959+
4960+ public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> LeaveSpaceHandle {
4961+ return LeaveSpaceHandle(unsafeFromRawPointer: pointer)
4962+ }
4963+
4964+ public static func lower(_ value: LeaveSpaceHandle) -> UnsafeMutableRawPointer {
4965+ return value.uniffiClonePointer()
4966+ }
4967+
4968+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LeaveSpaceHandle {
4969+ let v: UInt64 = try readInt(&buf)
4970+ // The Rust code won't compile if a pointer won't fit in a UInt64.
4971+ // We have to go via `UInt` because that's the thing that's the size of a pointer.
4972+ let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
4973+ if (ptr == nil) {
4974+ throw UniffiInternalError.unexpectedNullPointer
4975+ }
4976+ return try lift(ptr!)
4977+ }
4978+
4979+ public static func write(_ value: LeaveSpaceHandle, into buf: inout [UInt8]) {
4980+ // This fiddling is because `Int` is the thing that's the same size as a pointer.
4981+ // The Rust code won't compile if a pointer won't fit in a `UInt64`.
4982+ writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
4983+ }
4984+ }
4985+
4986+
4987+
4988+
4989+ public func FfiConverterTypeLeaveSpaceHandle_lift(_ pointer: UnsafeMutableRawPointer) throws -> LeaveSpaceHandle {
4990+ return try FfiConverterTypeLeaveSpaceHandle.lift(pointer)
4991+ }
4992+
4993+ public func FfiConverterTypeLeaveSpaceHandle_lower(_ value: LeaveSpaceHandle) -> UnsafeMutableRawPointer {
4994+ return FfiConverterTypeLeaveSpaceHandle.lower(value)
4995+ }
4996+
4997+
4998+
4999+
48495000/**
48505001 * A file handle that takes ownership of a media file on disk. When the handle
48515002 * is dropped, the file will be removed from the disk.
@@ -11318,6 +11469,17 @@ public protocol SpaceServiceProtocol : AnyObject {
1131811469 */
1131911470 func joinedSpaces() async -> [SpaceRoom]
1132011471
11472+ /**
11473+ * Start a space leave process returning a [`LeaveSpaceHandle`] from which
11474+ * rooms can be retrieved in reversed BFS order starting from the requested
11475+ * `space_id` graph node. If the room is unknown then an error will be
11476+ * returned.
11477+ *
11478+ * Once the rooms to be left are chosen the handle can be used to leave
11479+ * them.
11480+ */
11481+ func leaveSpace(spaceId: String) async throws -> LeaveSpaceHandle
11482+
1132111483 /**
1132211484 * Returns a `SpaceRoomList` for the given space ID.
1132311485 */
@@ -11402,6 +11564,32 @@ open func joinedSpaces()async -> [SpaceRoom] {
1140211564 )
1140311565}
1140411566
11567+ /**
11568+ * Start a space leave process returning a [`LeaveSpaceHandle`] from which
11569+ * rooms can be retrieved in reversed BFS order starting from the requested
11570+ * `space_id` graph node. If the room is unknown then an error will be
11571+ * returned.
11572+ *
11573+ * Once the rooms to be left are chosen the handle can be used to leave
11574+ * them.
11575+ */
11576+ open func leaveSpace(spaceId: String)async throws -> LeaveSpaceHandle {
11577+ return
11578+ try await uniffiRustCallAsync(
11579+ rustFutureFunc: {
11580+ uniffi_matrix_sdk_ffi_fn_method_spaceservice_leave_space(
11581+ self.uniffiClonePointer(),
11582+ FfiConverterString.lower(spaceId)
11583+ )
11584+ },
11585+ pollFunc: ffi_matrix_sdk_ffi_rust_future_poll_pointer,
11586+ completeFunc: ffi_matrix_sdk_ffi_rust_future_complete_pointer,
11587+ freeFunc: ffi_matrix_sdk_ffi_rust_future_free_pointer,
11588+ liftFunc: FfiConverterTypeLeaveSpaceHandle.lift,
11589+ errorHandler: FfiConverterTypeClientError.lift
11590+ )
11591+ }
11592+
1140511593 /**
1140611594 * Returns a `SpaceRoomList` for the given space ID.
1140711595 */
@@ -15929,6 +16117,81 @@ public func FfiConverterTypeLastLocation_lower(_ value: LastLocation) -> RustBuf
1592916117}
1593016118
1593116119
16120+ /**
16121+ * Space leaving specific room that groups normal [`SpaceRoom`] details with
16122+ * information about the leaving user's role.
16123+ */
16124+ public struct LeaveSpaceRoom {
16125+ /**
16126+ * The underlying [`SpaceRoom`]
16127+ */
16128+ public var spaceRoom: SpaceRoom
16129+ /**
16130+ * Whether the user is the last admin in the room. This helps clients
16131+ * better inform the user about the consequences of leaving the room.
16132+ */
16133+ public var isLastAdmin: Bool
16134+
16135+ // Default memberwise initializers are never public by default, so we
16136+ // declare one manually.
16137+ public init(
16138+ /**
16139+ * The underlying [`SpaceRoom`]
16140+ */spaceRoom: SpaceRoom,
16141+ /**
16142+ * Whether the user is the last admin in the room. This helps clients
16143+ * better inform the user about the consequences of leaving the room.
16144+ */isLastAdmin: Bool) {
16145+ self.spaceRoom = spaceRoom
16146+ self.isLastAdmin = isLastAdmin
16147+ }
16148+ }
16149+
16150+
16151+
16152+ extension LeaveSpaceRoom: Equatable, Hashable {
16153+ public static func ==(lhs: LeaveSpaceRoom, rhs: LeaveSpaceRoom) -> Bool {
16154+ if lhs.spaceRoom != rhs.spaceRoom {
16155+ return false
16156+ }
16157+ if lhs.isLastAdmin != rhs.isLastAdmin {
16158+ return false
16159+ }
16160+ return true
16161+ }
16162+
16163+ public func hash(into hasher: inout Hasher) {
16164+ hasher.combine(spaceRoom)
16165+ hasher.combine(isLastAdmin)
16166+ }
16167+ }
16168+
16169+
16170+ public struct FfiConverterTypeLeaveSpaceRoom: FfiConverterRustBuffer {
16171+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LeaveSpaceRoom {
16172+ return
16173+ try LeaveSpaceRoom(
16174+ spaceRoom: FfiConverterTypeSpaceRoom.read(from: &buf),
16175+ isLastAdmin: FfiConverterBool.read(from: &buf)
16176+ )
16177+ }
16178+
16179+ public static func write(_ value: LeaveSpaceRoom, into buf: inout [UInt8]) {
16180+ FfiConverterTypeSpaceRoom.write(value.spaceRoom, into: &buf)
16181+ FfiConverterBool.write(value.isLastAdmin, into: &buf)
16182+ }
16183+ }
16184+
16185+
16186+ public func FfiConverterTypeLeaveSpaceRoom_lift(_ buf: RustBuffer) throws -> LeaveSpaceRoom {
16187+ return try FfiConverterTypeLeaveSpaceRoom.lift(buf)
16188+ }
16189+
16190+ public func FfiConverterTypeLeaveSpaceRoom_lower(_ value: LeaveSpaceRoom) -> RustBuffer {
16191+ return FfiConverterTypeLeaveSpaceRoom.lower(value)
16192+ }
16193+
16194+
1593216195/**
1593316196 * Details of a users live location share.
1593416197 */
@@ -28329,10 +28592,16 @@ public enum RecoveryError {
2832928592 case Client(source: ClientError
2833028593 )
2833128594 /**
28332- * Error in the secret storage subsystem.
28595+ * Error in the secret storage subsystem, except for when importing a
28596+ * secret.
2833328597 */
2833428598 case SecretStorage(errorMessage: String
2833528599 )
28600+ /**
28601+ * Error when importing a secret from secret storage.
28602+ */
28603+ case Import(errorMessage: String
28604+ )
2833628605}
2833728606
2833828607
@@ -28353,6 +28622,9 @@ public struct FfiConverterTypeRecoveryError: FfiConverterRustBuffer {
2835328622 case 3: return .SecretStorage(
2835428623 errorMessage: try FfiConverterString.read(from: &buf)
2835528624 )
28625+ case 4: return .Import(
28626+ errorMessage: try FfiConverterString.read(from: &buf)
28627+ )
2835628628
2835728629 default: throw UniffiInternalError.unexpectedEnumCase
2835828630 }
@@ -28378,6 +28650,11 @@ public struct FfiConverterTypeRecoveryError: FfiConverterRustBuffer {
2837828650 writeInt(&buf, Int32(3))
2837928651 FfiConverterString.write(errorMessage, into: &buf)
2838028652
28653+
28654+ case let .Import(errorMessage):
28655+ writeInt(&buf, Int32(4))
28656+ FfiConverterString.write(errorMessage, into: &buf)
28657+
2838128658 }
2838228659 }
2838328660}
@@ -37362,6 +37639,28 @@ fileprivate struct FfiConverterSequenceTypeKnockRequest: FfiConverterRustBuffer
3736237639 }
3736337640}
3736437641
37642+ fileprivate struct FfiConverterSequenceTypeLeaveSpaceRoom: FfiConverterRustBuffer {
37643+ typealias SwiftType = [LeaveSpaceRoom]
37644+
37645+ public static func write(_ value: [LeaveSpaceRoom], into buf: inout [UInt8]) {
37646+ let len = Int32(value.count)
37647+ writeInt(&buf, len)
37648+ for item in value {
37649+ FfiConverterTypeLeaveSpaceRoom.write(item, into: &buf)
37650+ }
37651+ }
37652+
37653+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LeaveSpaceRoom] {
37654+ let len: Int32 = try readInt(&buf)
37655+ var seq = [LeaveSpaceRoom]()
37656+ seq.reserveCapacity(Int(len))
37657+ for _ in 0 ..< len {
37658+ seq.append(try FfiConverterTypeLeaveSpaceRoom.read(from: &buf))
37659+ }
37660+ return seq
37661+ }
37662+ }
37663+
3736537664fileprivate struct FfiConverterSequenceTypeLiveLocationShare: FfiConverterRustBuffer {
3736637665 typealias SwiftType = [LiveLocationShare]
3736737666
@@ -39201,6 +39500,12 @@ private var initializationResult: InitializationResult = {
3920139500 if (uniffi_matrix_sdk_ffi_checksum_method_lazytimelineitemprovider_get_shields() != 12518) {
3920239501 return InitializationResult.apiChecksumMismatch
3920339502 }
39503+ if (uniffi_matrix_sdk_ffi_checksum_method_leavespacehandle_leave() != 54036) {
39504+ return InitializationResult.apiChecksumMismatch
39505+ }
39506+ if (uniffi_matrix_sdk_ffi_checksum_method_leavespacehandle_rooms() != 50920) {
39507+ return InitializationResult.apiChecksumMismatch
39508+ }
3920439509 if (uniffi_matrix_sdk_ffi_checksum_method_mediafilehandle_path() != 16357) {
3920539510 return InitializationResult.apiChecksumMismatch
3920639511 }
@@ -39789,6 +40094,9 @@ private var initializationResult: InitializationResult = {
3978940094 if (uniffi_matrix_sdk_ffi_checksum_method_spaceservice_joined_spaces() != 54285) {
3979040095 return InitializationResult.apiChecksumMismatch
3979140096 }
40097+ if (uniffi_matrix_sdk_ffi_checksum_method_spaceservice_leave_space() != 7949) {
40098+ return InitializationResult.apiChecksumMismatch
40099+ }
3979240100 if (uniffi_matrix_sdk_ffi_checksum_method_spaceservice_space_room_list() != 6768) {
3979340101 return InitializationResult.apiChecksumMismatch
3979440102 }
0 commit comments