Skip to content

Commit 6098f13

Browse files
Daniel SalinasDaniel Salinas
authored andcommitted
Send/Sync bounds
1 parent 7cda6d2 commit 6098f13

File tree

32 files changed

+215
-72
lines changed

32 files changed

+215
-72
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use matrix_sdk::{
4141
AuthApi, AuthSession, Client as MatrixClient, SessionChange, SessionTokens,
4242
STATE_STORE_DATABASE_NAME,
4343
};
44+
use matrix_sdk_common::{AsyncTraitDeps, SendOutsideWasm, SyncOutsideWasm};
4445
use matrix_sdk_ui::{
4546
notification_client::{
4647
NotificationClient as MatrixNotificationClient,
@@ -166,39 +167,39 @@ impl From<PushFormat> for RumaPushFormat {
166167
}
167168

168169
#[matrix_sdk_ffi_macros::export(callback_interface)]
169-
pub trait ClientDelegate: Sync + Send {
170+
pub trait ClientDelegate: SyncOutsideWasm + SendOutsideWasm {
170171
fn did_receive_auth_error(&self, is_soft_logout: bool);
171172
}
172173

173174
#[matrix_sdk_ffi_macros::export(callback_interface)]
174-
pub trait ClientSessionDelegate: Sync + Send {
175+
pub trait ClientSessionDelegate: AsyncTraitDeps {
175176
fn retrieve_session_from_keychain(&self, user_id: String) -> Result<Session, ClientError>;
176177
fn save_session_in_keychain(&self, session: Session);
177178
}
178179

179180
#[matrix_sdk_ffi_macros::export(callback_interface)]
180-
pub trait ProgressWatcher: Send + Sync {
181+
pub trait ProgressWatcher: SendOutsideWasm + SyncOutsideWasm {
181182
fn transmission_progress(&self, progress: TransmissionProgress);
182183
}
183184

184185
/// A listener to the global (client-wide) error reporter of the send queue.
185186
#[matrix_sdk_ffi_macros::export(callback_interface)]
186-
pub trait SendQueueRoomErrorListener: Sync + Send {
187+
pub trait SendQueueRoomErrorListener: SyncOutsideWasm + SendOutsideWasm {
187188
/// Called every time the send queue has ran into an error for a given room,
188189
/// which will disable the send queue for that particular room.
189190
fn on_error(&self, room_id: String, error: ClientError);
190191
}
191192

192193
/// A listener for changes of global account data events.
193194
#[matrix_sdk_ffi_macros::export(callback_interface)]
194-
pub trait AccountDataListener: Sync + Send {
195+
pub trait AccountDataListener: SyncOutsideWasm + SendOutsideWasm {
195196
/// Called when a global account data event has changed.
196197
fn on_change(&self, event: AccountDataEvent);
197198
}
198199

199200
/// A listener for changes of room account data events.
200201
#[matrix_sdk_ffi_macros::export(callback_interface)]
201-
pub trait RoomAccountDataListener: Sync + Send {
202+
pub trait RoomAccountDataListener: SyncOutsideWasm + SendOutsideWasm {
202203
/// Called when a room account data event was changed.
203204
fn on_change(&self, event: RoomAccountDataEvent, room_id: String);
204205
}
@@ -1555,12 +1556,12 @@ impl Client {
15551556
}
15561557

15571558
#[matrix_sdk_ffi_macros::export(callback_interface)]
1558-
pub trait MediaPreviewConfigListener: Sync + Send {
1559+
pub trait MediaPreviewConfigListener: SyncOutsideWasm + SendOutsideWasm {
15591560
fn on_change(&self, media_preview_config: Option<MediaPreviewConfig>);
15601561
}
15611562

15621563
#[matrix_sdk_ffi_macros::export(callback_interface)]
1563-
pub trait IgnoredUsersListener: Sync + Send {
1564+
pub trait IgnoredUsersListener: SyncOutsideWasm + SendOutsideWasm {
15641565
fn call(&self, ignored_user_ids: Vec<String>);
15651566
}
15661567

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{fs, num::NonZeroUsize, path::Path, sync::Arc, time::Duration};
22

3+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
4+
35
use async_compat::get_runtime_handle;
46
use futures_util::StreamExt;
57
use matrix_sdk::{
@@ -173,7 +175,7 @@ pub enum QrLoginProgress {
173175
}
174176

175177
#[matrix_sdk_ffi_macros::export(callback_interface)]
176-
pub trait QrLoginProgressListener: Sync + Send {
178+
pub trait QrLoginProgressListener: SyncOutsideWasm + SendOutsideWasm {
177179
fn on_update(&self, state: QrLoginProgress);
178180
}
179181

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use matrix_sdk::{
66
encryption,
77
encryption::{backups, recovery},
88
};
9+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
910
use thiserror::Error;
1011
use tracing::{error, info};
1112
use zeroize::Zeroize;
@@ -25,22 +26,22 @@ pub struct Encryption {
2526
}
2627

2728
#[matrix_sdk_ffi_macros::export(callback_interface)]
28-
pub trait BackupStateListener: Sync + Send {
29+
pub trait BackupStateListener: SyncOutsideWasm + SendOutsideWasm {
2930
fn on_update(&self, status: BackupState);
3031
}
3132

3233
#[matrix_sdk_ffi_macros::export(callback_interface)]
33-
pub trait BackupSteadyStateListener: Sync + Send {
34+
pub trait BackupSteadyStateListener: SyncOutsideWasm + SendOutsideWasm {
3435
fn on_update(&self, status: BackupUploadState);
3536
}
3637

3738
#[matrix_sdk_ffi_macros::export(callback_interface)]
38-
pub trait RecoveryStateListener: Sync + Send {
39+
pub trait RecoveryStateListener: SyncOutsideWasm + SendOutsideWasm {
3940
fn on_update(&self, status: RecoveryState);
4041
}
4142

4243
#[matrix_sdk_ffi_macros::export(callback_interface)]
43-
pub trait VerificationStateListener: Sync + Send {
44+
pub trait VerificationStateListener: SyncOutsideWasm + SendOutsideWasm {
4445
fn on_update(&self, status: VerificationState);
4546
}
4647

@@ -164,7 +165,7 @@ impl From<recovery::RecoveryState> for RecoveryState {
164165
}
165166

166167
#[matrix_sdk_ffi_macros::export(callback_interface)]
167-
pub trait EnableRecoveryProgressListener: Sync + Send {
168+
pub trait EnableRecoveryProgressListener: SyncOutsideWasm + SendOutsideWasm {
168169
fn on_update(&self, status: EnableRecoveryProgress);
169170
}
170171

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use matrix_sdk::{
99
ruma::events::push_rules::PushRulesEvent,
1010
Client as MatrixClient,
1111
};
12+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
1213
use ruma::{
1314
push::{
1415
Action as SdkAction, ComparisonOperator as SdkComparisonOperator, PredefinedOverrideRuleId,
@@ -387,7 +388,7 @@ impl From<RoomNotificationMode> for SdkRoomNotificationMode {
387388

388389
/// Delegate to notify of changes in push rules
389390
#[matrix_sdk_ffi_macros::export(callback_interface)]
390-
pub trait NotificationSettingsDelegate: Sync + Send {
391+
pub trait NotificationSettingsDelegate: SyncOutsideWasm + SendOutsideWasm {
391392
fn settings_did_change(&self);
392393
}
393394

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ use ruma::{
3535
};
3636
use tracing::{error, warn};
3737

38+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
39+
3840
use crate::{
3941
chunk_iterator::ChunkIterator,
4042
client::{JoinRule, RoomVisibility},
@@ -1173,7 +1175,7 @@ impl Room {
11731175

11741176
/// A listener for receiving new live location shares in a room.
11751177
#[matrix_sdk_ffi_macros::export(callback_interface)]
1176-
pub trait LiveLocationShareListener: Sync + Send {
1178+
pub trait LiveLocationShareListener: SyncOutsideWasm + SendOutsideWasm {
11771179
fn call(&self, live_location_shares: Vec<LiveLocationShare>);
11781180
}
11791181

@@ -1195,7 +1197,7 @@ impl From<matrix_sdk::room::knock_requests::KnockRequest> for KnockRequest {
11951197

11961198
/// A listener for receiving new requests to a join a room.
11971199
#[matrix_sdk_ffi_macros::export(callback_interface)]
1198-
pub trait KnockRequestsListener: Send + Sync {
1200+
pub trait KnockRequestsListener: SendOutsideWasm + SyncOutsideWasm {
11991201
fn call(&self, join_requests: Vec<KnockRequest>);
12001202
}
12011203

@@ -1315,17 +1317,17 @@ impl From<RumaPowerLevels> for RoomPowerLevels {
13151317
}
13161318

13171319
#[matrix_sdk_ffi_macros::export(callback_interface)]
1318-
pub trait RoomInfoListener: Sync + Send {
1320+
pub trait RoomInfoListener: SyncOutsideWasm + SendOutsideWasm {
13191321
fn call(&self, room_info: RoomInfo);
13201322
}
13211323

13221324
#[matrix_sdk_ffi_macros::export(callback_interface)]
1323-
pub trait TypingNotificationsListener: Sync + Send {
1325+
pub trait TypingNotificationsListener: SyncOutsideWasm + SendOutsideWasm {
13241326
fn call(&self, typing_user_ids: Vec<String>);
13251327
}
13261328

13271329
#[matrix_sdk_ffi_macros::export(callback_interface)]
1328-
pub trait IdentityStatusChangeListener: Sync + Send {
1330+
pub trait IdentityStatusChangeListener: SyncOutsideWasm + SendOutsideWasm {
13291331
fn call(&self, identity_status_change: Vec<IdentityStatusChange>);
13301332
}
13311333

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use async_compat::get_runtime_handle;
1919
use eyeball_im::VectorDiff;
2020
use futures_util::StreamExt;
2121
use matrix_sdk::room_directory_search::RoomDirectorySearch as SdkRoomDirectorySearch;
22+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
2223
use ruma::ServerName;
2324
use tokio::sync::RwLock;
2425

@@ -198,6 +199,6 @@ impl From<VectorDiff<matrix_sdk::room_directory_search::RoomDescription>>
198199
}
199200

200201
#[matrix_sdk_ffi_macros::export(callback_interface)]
201-
pub trait RoomDirectorySearchEntriesListener: Send + Sync + Debug {
202+
pub trait RoomDirectorySearchEntriesListener: SendOutsideWasm + SyncOutsideWasm + Debug {
202203
fn on_update(&self, room_entries_update: Vec<RoomDirectorySearchEntryUpdate>);
203204
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use matrix_sdk::{
1212
},
1313
Room as SdkRoom,
1414
};
15+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
1516
use matrix_sdk_ui::{
1617
room_list_service::filters::{
1718
new_filter_all, new_filter_any, new_filter_category, new_filter_deduplicate_versions,
@@ -342,17 +343,17 @@ impl From<matrix_sdk_ui::room_list_service::RoomListLoadingState> for RoomListLo
342343
}
343344

344345
#[matrix_sdk_ffi_macros::export(callback_interface)]
345-
pub trait RoomListServiceStateListener: Send + Sync + Debug {
346+
pub trait RoomListServiceStateListener: SendOutsideWasm + SyncOutsideWasm + Debug {
346347
fn on_update(&self, state: RoomListServiceState);
347348
}
348349

349350
#[matrix_sdk_ffi_macros::export(callback_interface)]
350-
pub trait RoomListLoadingStateListener: Send + Sync + Debug {
351+
pub trait RoomListLoadingStateListener: SendOutsideWasm + SyncOutsideWasm + Debug {
351352
fn on_update(&self, state: RoomListLoadingState);
352353
}
353354

354355
#[matrix_sdk_ffi_macros::export(callback_interface)]
355-
pub trait RoomListServiceSyncIndicatorListener: Send + Sync + Debug {
356+
pub trait RoomListServiceSyncIndicatorListener: SendOutsideWasm + SyncOutsideWasm + Debug {
356357
fn on_update(&self, sync_indicator: RoomListServiceSyncIndicator);
357358
}
358359

@@ -412,7 +413,7 @@ impl RoomListEntriesUpdate {
412413
}
413414

414415
#[matrix_sdk_ffi_macros::export(callback_interface)]
415-
pub trait RoomListEntriesListener: Send + Sync + Debug {
416+
pub trait RoomListEntriesListener: SendOutsideWasm + SyncOutsideWasm + Debug {
416417
fn on_update(&self, room_entries_update: Vec<RoomListEntriesUpdate>);
417418
}
418419

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use matrix_sdk::{
1111
ruma::events::key::verification::VerificationMethod,
1212
Account,
1313
};
14+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
1415
use ruma::UserId;
1516
use tracing::{error, warn};
1617

@@ -51,7 +52,7 @@ pub struct SessionVerificationRequestDetails {
5152
}
5253

5354
#[matrix_sdk_ffi_macros::export(callback_interface)]
54-
pub trait SessionVerificationControllerDelegate: Sync + Send {
55+
pub trait SessionVerificationControllerDelegate: SyncOutsideWasm + SendOutsideWasm {
5556
fn did_receive_verification_request(&self, details: SessionVerificationRequestDetails);
5657
fn did_accept_verification_request(&self);
5758
fn did_start_sas_verification(&self);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::{fmt::Debug, sync::Arc};
1717
use async_compat::get_runtime_handle;
1818
use futures_util::pin_mut;
1919
use matrix_sdk::Client;
20+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
2021
use matrix_sdk_ui::{
2122
sync_service::{
2223
State as MatrixSyncServiceState, SyncService as MatrixSyncService,
@@ -51,7 +52,7 @@ impl From<MatrixSyncServiceState> for SyncServiceState {
5152
}
5253

5354
#[matrix_sdk_ffi_macros::export(callback_interface)]
54-
pub trait SyncServiceStateObserver: Send + Sync + Debug {
55+
pub trait SyncServiceStateObserver: SendOutsideWasm + SyncOutsideWasm + Debug {
5556
fn on_update(&self, state: SyncServiceState);
5657
}
5758

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ mod msg_like;
8585
mod reply;
8686

8787
use matrix_sdk::utils::formatted_body_from;
88+
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};
8889

8990
use crate::error::QueueWedgeError;
9091

@@ -807,12 +808,12 @@ pub enum FocusEventError {
807808
}
808809

809810
#[matrix_sdk_ffi_macros::export(callback_interface)]
810-
pub trait TimelineListener: Sync + Send {
811+
pub trait TimelineListener: SyncOutsideWasm + SendOutsideWasm {
811812
fn on_update(&self, diff: Vec<Arc<TimelineDiff>>);
812813
}
813814

814815
#[matrix_sdk_ffi_macros::export(callback_interface)]
815-
pub trait PaginationStatusListener: Sync + Send {
816+
pub trait PaginationStatusListener: SyncOutsideWasm + SendOutsideWasm {
816817
fn on_update(&self, status: RoomPaginationStatus);
817818
}
818819

0 commit comments

Comments
 (0)