From 570e6b93da6151afe85277e0a09ba47aec0ad781 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 4 Oct 2023 10:42:03 +0200 Subject: [PATCH] Upgrade UniFFI --- Cargo.lock | 80 ++++++++++++++------- Cargo.toml | 4 +- bindings/matrix-sdk-crypto-ffi/src/error.rs | 7 +- bindings/matrix-sdk-ffi/src/error.rs | 7 ++ bindings/matrix-sdk-ffi/src/room_list.rs | 7 +- xtask/src/kotlin.rs | 1 + xtask/src/swift.rs | 1 + 7 files changed, 79 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7711572f859..8116929f415 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1975,6 +1975,19 @@ dependencies = [ "thread_local", ] +[[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2800,6 +2813,20 @@ dependencies = [ "log", ] +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "pin-utils", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + [[package]] name = "mac" version = "0.1.1" @@ -3737,6 +3764,15 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oneshot" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f6640c6bda7731b1fdbab747981a0f896dd1fedaf9f4a53fa237a04a84431f4" +dependencies = [ + "loom", +] + [[package]] name = "oorandom" version = "11.1.3" @@ -6212,8 +6248,8 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "uniffi" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "camino", @@ -6233,8 +6269,8 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "askama", @@ -6248,7 +6284,6 @@ dependencies = [ "once_cell", "paste", "serde", - "serde_json", "toml 0.5.11", "uniffi_meta", "uniffi_testing", @@ -6257,8 +6292,8 @@ dependencies = [ [[package]] name = "uniffi_build" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "camino", @@ -6267,8 +6302,8 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "quote", "syn 2.0.38", @@ -6276,24 +6311,24 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "async-compat", "bytes", "camino", - "cargo_metadata", "log", "once_cell", + "oneshot", "paste", "static_assertions", ] [[package]] name = "uniffi_macros" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "bincode", "camino", @@ -6310,34 +6345,31 @@ dependencies = [ [[package]] name = "uniffi_meta" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "bytes", - "serde", "siphasher", "uniffi_checksum_derive", ] [[package]] name = "uniffi_testing" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "camino", "cargo_metadata", "fs-err", "once_cell", - "serde", - "serde_json", ] [[package]] name = "uniffi_udl" -version = "0.24.1" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +version = "0.24.3" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "anyhow", "uniffi_meta", @@ -6624,7 +6656,7 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "weedle2" version = "4.0.0" -source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" +source = "git+https://github.com/mozilla/uniffi-rs?rev=48b1f51f6e5406cab20f502f535b30a589a5b140#48b1f51f6e5406cab20f502f535b30a589a5b140" dependencies = [ "nom", ] diff --git a/Cargo.toml b/Cargo.toml index c041060a9f4..8b00eacf71b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,8 @@ thiserror = "1.0.38" tokio = { version = "1.30.0", default-features = false, features = ["sync"] } tracing = { version = "0.1.36", default-features = false, features = ["std"] } tracing-core = "0.1.30" -uniffi = { git = "https://github.com/mozilla/uniffi-rs", rev = "e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" } -uniffi_bindgen = { git = "https://github.com/mozilla/uniffi-rs", rev = "e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" } +uniffi = { git = "https://github.com/mozilla/uniffi-rs", rev = "48b1f51f6e5406cab20f502f535b30a589a5b140" } +uniffi_bindgen = { git = "https://github.com/mozilla/uniffi-rs", rev = "48b1f51f6e5406cab20f502f535b30a589a5b140" } vodozemac = "0.5.0" zeroize = "1.6.0" diff --git a/bindings/matrix-sdk-crypto-ffi/src/error.rs b/bindings/matrix-sdk-crypto-ffi/src/error.rs index 352e8e606a0..01e08d51a50 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/error.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/error.rs @@ -59,12 +59,17 @@ pub enum CryptoStoreError { Identifier(#[from] IdParseError), } -#[derive(Debug, uniffi::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum DecryptionError { + #[error("serialization error: {error}")] Serialization { error: String }, + #[error("identifier parsing error: {error}")] Identifier { error: String }, + #[error("megolm error: {error}")] Megolm { error: String }, + #[error("missing room key: {error}")] MissingRoomKey { error: String, withheld_code: Option }, + #[error("store error: {error}")] Store { error: String }, } diff --git a/bindings/matrix-sdk-ffi/src/error.rs b/bindings/matrix-sdk-ffi/src/error.rs index 39f2ebf3b88..554ffe34642 100644 --- a/bindings/matrix-sdk-ffi/src/error.rs +++ b/bindings/matrix-sdk-ffi/src/error.rs @@ -5,6 +5,7 @@ use matrix_sdk::{ NotificationSettingsError as SdkNotificationSettingsError, StoreError, }; use matrix_sdk_ui::{encryption_sync_service, notification_client, sync_service, timeline}; +use uniffi::UnexpectedUniFFICallbackError; #[derive(Debug, thiserror::Error)] pub enum ClientError { @@ -24,6 +25,12 @@ impl From for ClientError { } } +impl From for ClientError { + fn from(e: UnexpectedUniFFICallbackError) -> Self { + Self::new(e) + } +} + impl From for ClientError { fn from(e: matrix_sdk::Error) -> Self { Self::new(e) diff --git a/bindings/matrix-sdk-ffi/src/room_list.rs b/bindings/matrix-sdk-ffi/src/room_list.rs index a17f6fbc42f..6cb7c0432ba 100644 --- a/bindings/matrix-sdk-ffi/src/room_list.rs +++ b/bindings/matrix-sdk-ffi/src/room_list.rs @@ -23,12 +23,17 @@ use crate::{ RUNTIME, }; -#[derive(uniffi::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum RoomListError { + #[error("sliding sync error: {error}")] SlidingSync { error: String }, + #[error("unknown list `{list_name}`")] UnknownList { list_name: String }, + #[error("input cannot be applied")] InputCannotBeApplied, + #[error("room `{room_name}` not found")] RoomNotFound { room_name: String }, + #[error("invalid room ID: {error}")] InvalidRoomId { error: String }, } diff --git a/xtask/src/kotlin.rs b/xtask/src/kotlin.rs index 1266302b71f..9f5199790b0 100644 --- a/xtask/src/kotlin.rs +++ b/xtask/src/kotlin.rs @@ -140,6 +140,7 @@ fn generate_uniffi_bindings( vec![TargetLanguage::Kotlin], Some(ffi_generated_dir), Some(library_path), + None, false, )?; Ok(()) diff --git a/xtask/src/swift.rs b/xtask/src/swift.rs index d10d06ee6f2..5d072dedb7b 100644 --- a/xtask/src/swift.rs +++ b/xtask/src/swift.rs @@ -103,6 +103,7 @@ fn generate_uniffi(library_file: &Utf8Path, ffi_directory: &Utf8Path) -> Result< vec![TargetLanguage::Swift], Some(ffi_directory), Some(library_file), + None, false, )?; Ok(())