Skip to content

Commit a3225e5

Browse files
zzorbaDaniel SalinasDaniel SalinasjplatteHywan
authored
feat(wasm): Wasm equivalent of get_runtime_handle and corresponding tokio types (#5089)
Adds a Wasm equivalent of the get_runtime_handle method provided by tokio, as well as Handle/Runtime types that can be used on either Wasm or non-Wasm platforms interchangeably. Dependent on #5088 <!-- description of the changes in this PR --> - [ ] Public API changes documented in changelogs (optional) <!-- Sign-off, if not part of the commits --> <!-- See CONTRIBUTING.md if you don't know what this is --> Signed-off-by: Daniel Salinas --------- Signed-off-by: Daniel Salinas <zzorba@users.noreply.github.com> Co-authored-by: Daniel Salinas <danielsalinas@Daniels-MacBook-Pro-2.local> Co-authored-by: Daniel Salinas <danielsalinas@daniels-mbp-2.myfiosgateway.com> Co-authored-by: Jonas Platte <jplatte+git@posteo.de> Co-authored-by: Ivan Enderlin <ivan@mnt.io>
1 parent 0777e6e commit a3225e5

File tree

16 files changed

+130
-21
lines changed

16 files changed

+130
-21
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ as_variant = "1.3.0"
2525
assert-json-diff = "2.0.2"
2626
assert_matches = "1.5.0"
2727
assert_matches2 = "0.1.2"
28+
async-compat = "0.2.4"
2829
async-rx = "0.1.3"
2930
async-stream = "0.3.5"
3031
async-trait = "0.1.85"

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{
77
};
88

99
use anyhow::{anyhow, Context as _};
10-
use async_compat::get_runtime_handle;
1110
use futures_util::pin_mut;
1211
use matrix_sdk::{
1312
authentication::oauth::{
@@ -41,7 +40,9 @@ use matrix_sdk::{
4140
AuthApi, AuthSession, Client as MatrixClient, SessionChange, SessionTokens,
4241
STATE_STORE_DATABASE_NAME,
4342
};
44-
use matrix_sdk_common::{stream::StreamExt, SendOutsideWasm, SyncOutsideWasm};
43+
use matrix_sdk_common::{
44+
runtime::get_runtime_handle, stream::StreamExt, SendOutsideWasm, SyncOutsideWasm,
45+
};
4546
use matrix_sdk_ui::{
4647
notification_client::{
4748
NotificationClient as MatrixNotificationClient,

bindings/matrix-sdk-ffi/src/client_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::{fs, num::NonZeroUsize, path::Path, sync::Arc, time::Duration};
22

3-
use async_compat::get_runtime_handle;
43
use futures_util::StreamExt;
54
use matrix_sdk::{
65
authentication::oauth::qrcode::{self, DeviceCodeErrorResponseType, LoginFailureReason},
@@ -19,7 +18,7 @@ use matrix_sdk::{
1918
Client as MatrixClient, ClientBuildError as MatrixClientBuildError, HttpError, IdParseError,
2019
RumaApiError, SqliteStoreConfig,
2120
};
22-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
21+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
2322
use ruma::api::error::{DeserializationError, FromHttpResponseError};
2423
use tracing::{debug, error};
2524
use zeroize::Zeroizing;

bindings/matrix-sdk-ffi/src/encryption.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::sync::Arc;
22

3-
use async_compat::get_runtime_handle;
43
use futures_util::StreamExt;
54
use matrix_sdk::{
65
encryption,
76
encryption::{backups, recovery},
87
};
9-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
8+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
109
use thiserror::Error;
1110
use tracing::{error, info};
1211
use zeroize::Zeroize;

bindings/matrix-sdk-ffi/src/room.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{collections::HashMap, pin::pin, sync::Arc};
22

33
use anyhow::{Context, Result};
4-
use async_compat::get_runtime_handle;
54
use futures_util::{pin_mut, StreamExt};
65
use matrix_sdk::{
76
crypto::LocalTrust,
@@ -13,7 +12,7 @@ use matrix_sdk::{
1312
PredecessorRoom as SdkPredecessorRoom, RoomHero as SdkRoomHero, RoomMemberships, RoomState,
1413
SuccessorRoom as SdkSuccessorRoom,
1514
};
16-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
15+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
1716
use matrix_sdk_ui::{
1817
timeline::{default_event_filter, RoomExt, TimelineBuilder},
1918
unable_to_decrypt_hook::UtdHookManager,

bindings/matrix-sdk-ffi/src/room_directory_search.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515

1616
use std::{fmt::Debug, sync::Arc};
1717

18-
use async_compat::get_runtime_handle;
1918
use eyeball_im::VectorDiff;
2019
use futures_util::StreamExt;
2120
use matrix_sdk::room_directory_search::RoomDirectorySearch as SdkRoomDirectorySearch;
22-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
21+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
2322
use ruma::ServerName;
2423
use tokio::sync::RwLock;
2524

bindings/matrix-sdk-ffi/src/room_list.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use std::{fmt::Debug, mem::MaybeUninit, ptr::addr_of_mut, sync::Arc, time::Duration};
44

5-
use async_compat::get_runtime_handle;
65
use eyeball_im::VectorDiff;
76
use futures_util::{pin_mut, StreamExt};
87
use matrix_sdk::{
@@ -12,7 +11,7 @@ use matrix_sdk::{
1211
},
1312
Room as SdkRoom,
1413
};
15-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
14+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
1615
use matrix_sdk_ui::{
1716
room_list_service::filters::{
1817
new_filter_all, new_filter_any, new_filter_category, new_filter_deduplicate_versions,

bindings/matrix-sdk-ffi/src/session_verification.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::sync::{Arc, RwLock};
22

3-
use async_compat::get_runtime_handle;
43
use futures_util::StreamExt;
54
use matrix_sdk::{
65
encryption::{
@@ -11,7 +10,7 @@ use matrix_sdk::{
1110
ruma::events::key::verification::VerificationMethod,
1211
Account,
1312
};
14-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
13+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
1514
use ruma::UserId;
1615
use tracing::{error, warn};
1716

bindings/matrix-sdk-ffi/src/sync_service.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use std::{fmt::Debug, sync::Arc};
1616

17-
use async_compat::get_runtime_handle;
1817
use futures_util::pin_mut;
1918
use matrix_sdk::Client;
20-
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
19+
use matrix_sdk_common::{runtime::get_runtime_handle, SendOutsideWasm, SyncOutsideWasm};
2120
use matrix_sdk_ui::{
2221
sync_service::{
2322
State as MatrixSyncServiceState, SyncService as MatrixSyncService,

0 commit comments

Comments
 (0)