Skip to content

Commit 76e08b3

Browse files
github-actionsganfra
authored andcommitted
Bump SDK version to 0.2.32 (matrix-rust-sdk to 62137e5a3ef032a5f4c3ff77f98f5d0051bf55ad)
1 parent 6123ceb commit 76e08b3

File tree

6 files changed

+1120
-351
lines changed

6 files changed

+1120
-351
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object BuildVersionsSDK {
22
const val majorVersion = 0
33
const val minorVersion = 2
4-
const val patchVersion = 31
4+
const val patchVersion = 32
55
}

sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt

Lines changed: 931 additions & 272 deletions
Large diffs are not rendered by default.

sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk/matrix_sdk.kt

Lines changed: 93 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@file:Suppress("NAME_SHADOWING")
55

6-
package uniffi.matrix_sdk;
6+
package uniffi.matrix_sdk
77

88
// Common helper code.
99
//
@@ -235,7 +235,7 @@ internal open class UniffiRustCallStatus : Structure() {
235235
}
236236
}
237237

238-
class InternalException(message: String) : Exception(message)
238+
class InternalException(message: String) : kotlin.Exception(message)
239239

240240
// Each top-level error class has a companion object that can lift the error from the call status's rust buffer
241241
interface UniffiRustCallStatusErrorHandler<E> {
@@ -247,15 +247,15 @@ interface UniffiRustCallStatusErrorHandler<E> {
247247
// synchronize itself
248248

249249
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
250-
private inline fun <U, E: Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
251-
var status = UniffiRustCallStatus();
250+
private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
251+
var status = UniffiRustCallStatus()
252252
val return_value = callback(status)
253253
uniffiCheckCallStatus(errorHandler, status)
254254
return return_value
255255
}
256256

257257
// Check UniffiRustCallStatus and throw an error if the call wasn't successful
258-
private fun<E: Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
258+
private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
259259
if (status.isSuccess()) {
260260
return
261261
} else if (status.isError()) {
@@ -284,7 +284,7 @@ object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<In
284284

285285
// Call a rust function that returns a plain value
286286
private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
287-
return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback);
287+
return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
288288
}
289289

290290
internal inline fun<T> uniffiTraitInterfaceCall(
@@ -294,7 +294,7 @@ internal inline fun<T> uniffiTraitInterfaceCall(
294294
) {
295295
try {
296296
writeReturn(makeCall())
297-
} catch(e: Exception) {
297+
} catch(e: kotlin.Exception) {
298298
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
299299
callStatus.error_buf = FfiConverterString.lower(e.toString())
300300
}
@@ -308,7 +308,7 @@ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
308308
) {
309309
try {
310310
writeReturn(makeCall())
311-
} catch(e: Exception) {
311+
} catch(e: kotlin.Exception) {
312312
if (e is E) {
313313
callStatus.code = UNIFFI_CALL_ERROR
314314
callStatus.error_buf = lowerError(e)
@@ -1466,71 +1466,132 @@ public object FfiConverterTypePaginatorState: FfiConverterRustBuffer<PaginatorSt
14661466

14671467

14681468

1469+
1470+
14691471
/**
14701472
* The error type for failures while trying to log in a new device using a QR
14711473
* code.
14721474
*/
1473-
1474-
enum class QrCodeLoginError {
1475-
1475+
sealed class QrCodeLoginException(message: String): kotlin.Exception(message) {
1476+
14761477
/**
14771478
* An error happened while we were communicating with the OIDC provider.
14781479
*/
1479-
OIDC,
1480+
class Oidc(message: String) : QrCodeLoginException(message)
1481+
14801482
/**
14811483
* The other device has signaled to us that the login has failed.
14821484
*/
1483-
LOGIN_FAILURE,
1485+
class LoginFailure(message: String) : QrCodeLoginException(message)
1486+
14841487
/**
14851488
* An unexpected message was received from the other device.
14861489
*/
1487-
UNEXPECTED_MESSAGE,
1490+
class UnexpectedMessage(message: String) : QrCodeLoginException(message)
1491+
14881492
/**
14891493
* An error happened while exchanging messages with the other device.
14901494
*/
1491-
SECURE_CHANNEL,
1495+
class SecureChannel(message: String) : QrCodeLoginException(message)
1496+
14921497
/**
14931498
* The cross-process refresh lock failed to be initialized.
14941499
*/
1495-
CROSS_PROCESS_REFRESH_LOCK,
1500+
class CrossProcessRefreshLock(message: String) : QrCodeLoginException(message)
1501+
14961502
/**
14971503
* An error happened while we were trying to discover our user and device
14981504
* ID, after we have acquired an access token from the OIDC provider.
14991505
*/
1500-
USER_ID_DISCOVERY,
1506+
class UserIdDiscovery(message: String) : QrCodeLoginException(message)
1507+
15011508
/**
15021509
* We failed to set the session tokens after we figured out our device and
15031510
* user IDs.
15041511
*/
1505-
SESSION_TOKENS,
1512+
class SessionTokens(message: String) : QrCodeLoginException(message)
1513+
15061514
/**
15071515
* The device keys failed to be uploaded after we successfully logged in.
15081516
*/
1509-
DEVICE_KEY_UPLOAD,
1517+
class DeviceKeyUpload(message: String) : QrCodeLoginException(message)
1518+
15101519
/**
15111520
* The secrets bundle we received from the existing device failed to be
15121521
* imported.
15131522
*/
1514-
SECRET_IMPORT;
1515-
companion object
1516-
}
1517-
1523+
class SecretImport(message: String) : QrCodeLoginException(message)
1524+
15181525

1519-
public object FfiConverterTypeQRCodeLoginError: FfiConverterRustBuffer<QrCodeLoginError> {
1520-
override fun read(buf: ByteBuffer) = try {
1521-
QrCodeLoginError.values()[buf.getInt() - 1]
1522-
} catch (e: IndexOutOfBoundsException) {
1523-
throw RuntimeException("invalid enum value, something is very wrong!!", e)
1526+
companion object ErrorHandler : UniffiRustCallStatusErrorHandler<QrCodeLoginException> {
1527+
override fun lift(error_buf: RustBuffer.ByValue): QrCodeLoginException = FfiConverterTypeQRCodeLoginError.lift(error_buf)
15241528
}
1529+
}
15251530

1526-
override fun allocationSize(value: QrCodeLoginError) = 4UL
1531+
public object FfiConverterTypeQRCodeLoginError : FfiConverterRustBuffer<QrCodeLoginException> {
1532+
override fun read(buf: ByteBuffer): QrCodeLoginException {
1533+
1534+
return when(buf.getInt()) {
1535+
1 -> QrCodeLoginException.Oidc(FfiConverterString.read(buf))
1536+
2 -> QrCodeLoginException.LoginFailure(FfiConverterString.read(buf))
1537+
3 -> QrCodeLoginException.UnexpectedMessage(FfiConverterString.read(buf))
1538+
4 -> QrCodeLoginException.SecureChannel(FfiConverterString.read(buf))
1539+
5 -> QrCodeLoginException.CrossProcessRefreshLock(FfiConverterString.read(buf))
1540+
6 -> QrCodeLoginException.UserIdDiscovery(FfiConverterString.read(buf))
1541+
7 -> QrCodeLoginException.SessionTokens(FfiConverterString.read(buf))
1542+
8 -> QrCodeLoginException.DeviceKeyUpload(FfiConverterString.read(buf))
1543+
9 -> QrCodeLoginException.SecretImport(FfiConverterString.read(buf))
1544+
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
1545+
}
1546+
1547+
}
15271548

1528-
override fun write(value: QrCodeLoginError, buf: ByteBuffer) {
1529-
buf.putInt(value.ordinal + 1)
1549+
override fun allocationSize(value: QrCodeLoginException): ULong {
1550+
return 4UL
15301551
}
1531-
}
15321552

1553+
override fun write(value: QrCodeLoginException, buf: ByteBuffer) {
1554+
when(value) {
1555+
is QrCodeLoginException.Oidc -> {
1556+
buf.putInt(1)
1557+
Unit
1558+
}
1559+
is QrCodeLoginException.LoginFailure -> {
1560+
buf.putInt(2)
1561+
Unit
1562+
}
1563+
is QrCodeLoginException.UnexpectedMessage -> {
1564+
buf.putInt(3)
1565+
Unit
1566+
}
1567+
is QrCodeLoginException.SecureChannel -> {
1568+
buf.putInt(4)
1569+
Unit
1570+
}
1571+
is QrCodeLoginException.CrossProcessRefreshLock -> {
1572+
buf.putInt(5)
1573+
Unit
1574+
}
1575+
is QrCodeLoginException.UserIdDiscovery -> {
1576+
buf.putInt(6)
1577+
Unit
1578+
}
1579+
is QrCodeLoginException.SessionTokens -> {
1580+
buf.putInt(7)
1581+
Unit
1582+
}
1583+
is QrCodeLoginException.DeviceKeyUpload -> {
1584+
buf.putInt(8)
1585+
Unit
1586+
}
1587+
is QrCodeLoginException.SecretImport -> {
1588+
buf.putInt(9)
1589+
Unit
1590+
}
1591+
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
1592+
}
15331593

1594+
}
15341595

15351596

15361597

sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_base/matrix_sdk_base.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@file:Suppress("NAME_SHADOWING")
55

6-
package uniffi.matrix_sdk_base;
6+
package uniffi.matrix_sdk_base
77

88
// Common helper code.
99
//
@@ -234,7 +234,7 @@ internal open class UniffiRustCallStatus : Structure() {
234234
}
235235
}
236236

237-
class InternalException(message: String) : Exception(message)
237+
class InternalException(message: String) : kotlin.Exception(message)
238238

239239
// Each top-level error class has a companion object that can lift the error from the call status's rust buffer
240240
interface UniffiRustCallStatusErrorHandler<E> {
@@ -246,15 +246,15 @@ interface UniffiRustCallStatusErrorHandler<E> {
246246
// synchronize itself
247247

248248
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
249-
private inline fun <U, E: Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
250-
var status = UniffiRustCallStatus();
249+
private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
250+
var status = UniffiRustCallStatus()
251251
val return_value = callback(status)
252252
uniffiCheckCallStatus(errorHandler, status)
253253
return return_value
254254
}
255255

256256
// Check UniffiRustCallStatus and throw an error if the call wasn't successful
257-
private fun<E: Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
257+
private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
258258
if (status.isSuccess()) {
259259
return
260260
} else if (status.isError()) {
@@ -283,7 +283,7 @@ object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<In
283283

284284
// Call a rust function that returns a plain value
285285
private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
286-
return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback);
286+
return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
287287
}
288288

289289
internal inline fun<T> uniffiTraitInterfaceCall(
@@ -293,7 +293,7 @@ internal inline fun<T> uniffiTraitInterfaceCall(
293293
) {
294294
try {
295295
writeReturn(makeCall())
296-
} catch(e: Exception) {
296+
} catch(e: kotlin.Exception) {
297297
callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
298298
callStatus.error_buf = FfiConverterString.lower(e.toString())
299299
}
@@ -307,7 +307,7 @@ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
307307
) {
308308
try {
309309
writeReturn(makeCall())
310-
} catch(e: Exception) {
310+
} catch(e: kotlin.Exception) {
311311
if (e is E) {
312312
callStatus.code = UNIFFI_CALL_ERROR
313313
callStatus.error_buf = lowerError(e)

0 commit comments

Comments
 (0)