From b4faef7867d172c0b7edd1bf7e4589c41fbbf3ed Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 27 Apr 2023 14:47:11 +0200 Subject: [PATCH] bindings: Use proc-macros for types no longer referenced in UDL --- bindings/matrix-sdk-crypto-ffi/src/error.rs | 3 ++- bindings/matrix-sdk-crypto-ffi/src/olm.udl | 10 ---------- bindings/matrix-sdk-ffi/src/api.udl | 13 ------------- bindings/matrix-sdk-ffi/src/error.rs | 2 +- bindings/matrix-sdk-ffi/src/tracing.rs | 1 + 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/error.rs b/bindings/matrix-sdk-crypto-ffi/src/error.rs index 04bcc9e55..3cb6d30fe 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/error.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/error.rs @@ -42,7 +42,8 @@ pub enum SignatureError { UnknownUserIdentity(String), } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] +#[uniffi(flat_error)] pub enum CryptoStoreError { #[error("Failed to open the store")] OpenStore(#[from] OpenStoreError), diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl index e9480a2d7..71adf3d83 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ b/bindings/matrix-sdk-crypto-ffi/src/olm.udl @@ -8,16 +8,6 @@ callback interface ProgressListener { void on_progress(i32 progress, i32 total); }; -[Error] -enum CryptoStoreError { - "OpenStore", - "CryptoStore", - "OlmError", - "Serialization", - "InvalidUserId", - "Identifier", -}; - dictionary CancelInfo { string cancel_code; string reason; diff --git a/bindings/matrix-sdk-ffi/src/api.udl b/bindings/matrix-sdk-ffi/src/api.udl index 0c0a2bf9a..dabf4c60d 100644 --- a/bindings/matrix-sdk-ffi/src/api.udl +++ b/bindings/matrix-sdk-ffi/src/api.udl @@ -1,10 +1,5 @@ namespace matrix_sdk_ffi {}; -[Error] -interface ClientError { - Generic(string msg); -}; - callback interface ClientDelegate { void did_receive_auth_error(boolean is_soft_logout); }; @@ -166,11 +161,3 @@ callback interface SessionVerificationControllerDelegate { void did_cancel(); void did_finish(); }; - -enum LogLevel { - "Error", - "Warn", - "Info", - "Debug", - "Trace", -}; diff --git a/bindings/matrix-sdk-ffi/src/error.rs b/bindings/matrix-sdk-ffi/src/error.rs index fe809fa71..ee9f01bdc 100644 --- a/bindings/matrix-sdk-ffi/src/error.rs +++ b/bindings/matrix-sdk-ffi/src/error.rs @@ -1,6 +1,6 @@ use matrix_sdk::{self, encryption::CryptoStoreError, HttpError, IdParseError, StoreError}; -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum ClientError { #[error("client error: {msg}")] Generic { msg: String }, diff --git a/bindings/matrix-sdk-ffi/src/tracing.rs b/bindings/matrix-sdk-ffi/src/tracing.rs index 6286bc13a..c530f33f3 100644 --- a/bindings/matrix-sdk-ffi/src/tracing.rs +++ b/bindings/matrix-sdk-ffi/src/tracing.rs @@ -170,6 +170,7 @@ impl Span { } } +#[derive(uniffi::Enum)] pub enum LogLevel { Error, Warn,