From aee2ef6abff63e2729a4fb197d772bf7e1336e86 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 13 Jul 2023 11:34:48 +0200 Subject: [PATCH] ffi: Use async-uniffi instead of block_on in app module --- bindings/matrix-sdk-ffi/src/app.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/app.rs b/bindings/matrix-sdk-ffi/src/app.rs index a4bba87d9..ad568f0ac 100644 --- a/bindings/matrix-sdk-ffi/src/app.rs +++ b/bindings/matrix-sdk-ffi/src/app.rs @@ -52,7 +52,7 @@ pub struct App { inner: MatrixApp, } -#[uniffi::export] +#[uniffi::export(async_runtime = "tokio")] impl App { pub fn room_list_service(&self) -> Arc { Arc::new(RoomListService { inner: self.inner.room_list_service() }) @@ -70,9 +70,9 @@ impl App { }))) } - pub fn start(&self) -> Result<(), ClientError> { + pub async fn start(&self) -> Result<(), ClientError> { let start = self.inner.start(); - RUNTIME.block_on(async { Ok(start.await?) }) + Ok(start.await?) } pub fn pause(&self) -> Result<(), ClientError> { @@ -91,7 +91,7 @@ impl AppBuilder { } } -#[uniffi::export] +#[uniffi::export(async_runtime = "tokio")] impl AppBuilder { pub fn with_encryption_sync( self: Arc, @@ -103,8 +103,8 @@ impl AppBuilder { Arc::new(Self { builder }) } - pub fn finish(self: Arc) -> Result, ClientError> { + pub async fn finish(self: Arc) -> Result, ClientError> { let this = unwrap_or_clone_arc(self); - RUNTIME.block_on(async move { Ok(Arc::new(App { inner: this.builder.build().await? })) }) + Ok(Arc::new(App { inner: this.builder.build().await? })) } }