diff --git a/Cargo.lock b/Cargo.lock index e74c4130d..5392dd34a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3132,6 +3132,7 @@ dependencies = [ "tokio-stream", "tracing", "ulid", + "uniffi", "vodozemac", "zeroize", ] diff --git a/bindings/matrix-sdk-crypto-ffi/Cargo.toml b/bindings/matrix-sdk-crypto-ffi/Cargo.toml index 09cdba866..176d1aee9 100644 --- a/bindings/matrix-sdk-crypto-ffi/Cargo.toml +++ b/bindings/matrix-sdk-crypto-ffi/Cargo.toml @@ -41,7 +41,7 @@ features = ["lax_deserialize"] [dependencies.matrix-sdk-crypto] workspace = true -features = ["qrcode", "automatic-room-key-forwarding"] +features = ["qrcode", "automatic-room-key-forwarding", "uniffi"] [dependencies.matrix-sdk-sqlite] workspace = true @@ -53,7 +53,6 @@ default_features = false features = ["rt-multi-thread"] [build-dependencies] -uniffi = { workspace = true, features = ["build"] } vergen = { version = "8.2.5", features = ["build", "git", "gitcl"] } [dev-dependencies] diff --git a/bindings/matrix-sdk-crypto-ffi/build.rs b/bindings/matrix-sdk-crypto-ffi/build.rs index d1502ae5c..a3572f17f 100644 --- a/bindings/matrix-sdk-crypto-ffi/build.rs +++ b/bindings/matrix-sdk-crypto-ffi/build.rs @@ -31,7 +31,6 @@ fn setup_x86_64_android_workaround() { fn main() -> Result<(), Box> { setup_x86_64_android_workaround(); - uniffi::generate_scaffolding("./src/olm.udl")?; EmitBuilder::builder().git_sha(true).git_describe(true, false, None).emit()?; diff --git a/bindings/matrix-sdk-crypto-ffi/src/lib.rs b/bindings/matrix-sdk-crypto-ffi/src/lib.rs index 6e6f1dd15..2b5290773 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/lib.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/lib.rs @@ -31,11 +31,10 @@ pub use logger::{set_logger, Logger}; pub use machine::{KeyRequestPair, OlmMachine, SignatureVerification}; use matrix_sdk_common::deserialized_responses::ShieldState as RustShieldState; use matrix_sdk_crypto::{ - backups::SignatureState, olm::{IdentityKeys, InboundGroupSession, Session}, store::{Changes, CryptoStore, PendingChanges, RoomSettings as RustRoomSettings}, types::{EventEncryptionAlgorithm as RustEventEncryptionAlgorithm, SigningKey}, - EncryptionSettings as RustEncryptionSettings, LocalTrust, + EncryptionSettings as RustEncryptionSettings, }; use matrix_sdk_sqlite::SqliteCryptoStore; pub use responses::{ @@ -886,7 +885,7 @@ fn vodozemac_version() -> String { vodozemac::VERSION.to_owned() } -uniffi::include_scaffolding!("olm"); +uniffi::setup_scaffolding!(); #[cfg(test)] mod tests { diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl deleted file mode 100644 index 6ab6cad7d..000000000 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ /dev/null @@ -1,15 +0,0 @@ -namespace matrix_sdk_crypto_ffi {}; - -enum LocalTrust { - "Verified", - "BlackListed", - "Ignored", - "Unset", -}; - -enum SignatureState { - "Missing", - "Invalid", - "ValidButNotTrusted", - "ValidAndTrusted", -}; diff --git a/crates/matrix-sdk-crypto/Cargo.toml b/crates/matrix-sdk-crypto/Cargo.toml index 1257eda92..b579e64d8 100644 --- a/crates/matrix-sdk-crypto/Cargo.toml +++ b/crates/matrix-sdk-crypto/Cargo.toml @@ -21,6 +21,7 @@ js = ["ruma/js", "vodozemac/js", "matrix-sdk-common/js"] qrcode = ["dep:matrix-sdk-qrcode"] message-ids = ["dep:ulid"] experimental-algorithms = [] +uniffi = ["dep:uniffi"] # Testing helpers for implementations based upon this testing = ["dep:http"] @@ -56,6 +57,7 @@ tokio = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true, features = ["attributes"] } ulid = { version = "1.0.0", optional = true } +uniffi = { workspace = true, optional = true } vodozemac = { workspace = true } zeroize = { workspace = true, features = ["zeroize_derive"] } diff --git a/crates/matrix-sdk-crypto/src/backups/mod.rs b/crates/matrix-sdk-crypto/src/backups/mod.rs index cdefd5218..6d73cbc35 100644 --- a/crates/matrix-sdk-crypto/src/backups/mod.rs +++ b/crates/matrix-sdk-crypto/src/backups/mod.rs @@ -108,6 +108,7 @@ impl SignatureVerification { /// The result of a signature check. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] pub enum SignatureState { /// The signature is missing. #[default] diff --git a/crates/matrix-sdk-crypto/src/identities/device.rs b/crates/matrix-sdk-crypto/src/identities/device.rs index b0174ce31..8f2683529 100644 --- a/crates/matrix-sdk-crypto/src/identities/device.rs +++ b/crates/matrix-sdk-crypto/src/identities/device.rs @@ -500,8 +500,9 @@ impl UserDevices { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] /// The local trust state of a device. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] pub enum LocalTrust { /// The device has been verified and is trusted. Verified = 0, diff --git a/crates/matrix-sdk-crypto/src/lib.rs b/crates/matrix-sdk-crypto/src/lib.rs index d3febf9c5..04396da14 100644 --- a/crates/matrix-sdk-crypto/src/lib.rs +++ b/crates/matrix-sdk-crypto/src/lib.rs @@ -107,3 +107,6 @@ pub static VERSION: &str = env!("CARGO_PKG_VERSION"); #[cfg(test)] matrix_sdk_test::init_tracing_for_tests!(); + +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!();