Skip to content

Commit 26943b1

Browse files
Daniel SalinasDaniel Salinas
Daniel Salinas
authored and
Daniel Salinas
committed
Restore some marker traits that were needed still
1 parent 246d70e commit 26943b1

File tree

17 files changed

+60
-52
lines changed

17 files changed

+60
-52
lines changed

crates/matrix-sdk-base/src/event_cache_store/traits.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::{fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
18+
use matrix_sdk_common::AsyncTraitDeps;
1819
use ruma::MxcUri;
1920

2021
use super::EventCacheStoreError;
@@ -24,7 +25,7 @@ use crate::media::MediaRequest;
2425
/// for the event cache of the SDK.
2526
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
2627
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
27-
pub trait EventCacheStore: Send + Sync {
28+
pub trait EventCacheStore: AsyncTraitDeps {
2829
/// The error type used by this event cache store.
2930
type Error: fmt::Debug + Into<EventCacheStoreError>;
3031

crates/matrix-sdk-base/src/read_receipts.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ use std::{
123123
};
124124

125125
use eyeball_im::Vector;
126-
use matrix_sdk_common::{deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer};
126+
use matrix_sdk_common::{
127+
deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer, SendOutsideWasm,
128+
SyncOutsideWasm,
129+
};
127130
use ruma::{
128131
events::{
129132
poll::{start::PollStartEventContent, unstable_start::UnstablePollStartEventContent},
@@ -266,16 +269,7 @@ impl RoomReadReceipts {
266269
}
267270

268271
/// Provider for timeline events prior to the current sync.
269-
#[cfg(not(target_arch = "wasm32"))]
270-
pub trait PreviousEventsProvider: Send + Sync {
271-
/// Returns the list of known timeline events, in sync order, for the given
272-
/// room.
273-
fn for_room(&self, room_id: &RoomId) -> Vector<SyncTimelineEvent>;
274-
}
275-
276-
/// Provider for timeline events prior to the current sync.
277-
#[cfg(target_arch = "wasm32")]
278-
pub trait PreviousEventsProvider {
272+
pub trait PreviousEventsProvider: SendOutsideWasm + SyncOutsideWasm {
279273
/// Returns the list of known timeline events, in sync order, for the given
280274
/// room.
281275
fn for_room(&self, room_id: &RoomId) -> Vector<SyncTimelineEvent>;

crates/matrix-sdk-base/src/store/memory_store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ impl MemoryStore {
137137
}
138138
}
139139

140-
#[async_trait]
140+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
141+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
141142
impl StateStore for MemoryStore {
142143
type Error = StoreError;
143144

crates/matrix-sdk-base/src/store/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ use tokio::sync::{broadcast, Mutex, RwLock};
5858
use tracing::warn;
5959

6060
use crate::{
61-
event_cache_store::{DynEventCacheStore, IntoEventCacheStore},
62-
rooms::{normal::RoomInfoNotableUpdate, RoomInfo, RoomState},
63-
MinimalRoomMemberEvent, Room, RoomStateFilter, SessionMeta
61+
event_cache_store::{DynEventCacheStore, IntoEventCacheStore},
62+
rooms::{normal::RoomInfoNotableUpdate, RoomInfo, RoomState},
63+
MinimalRoomMemberEvent, Room, RoomStateFilter, SessionMeta,
6464
};
6565

6666
pub(crate) mod ambiguity_map;

crates/matrix-sdk-base/src/store/observable_map.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ mod impl_non_wasm32 {
136136
#[cfg(target_arch = "wasm32")]
137137
mod impl_wasm32 {
138138
use std::{borrow::Borrow, collections::BTreeMap, hash::Hash};
139-
use futures_util::stream;
140-
use futures_util::{Stream, StreamExt};
139+
141140
use eyeball_im::{Vector, VectorDiff};
141+
use futures_util::{stream, Stream, StreamExt};
142142

143143
/// An observable map for Wasm. It's a simple wrapper around `BTreeMap`.
144144
#[derive(Debug)]
@@ -191,7 +191,8 @@ mod impl_wasm32 {
191191
/// Get a [`Stream`] of the values.
192192
pub(crate) fn stream(&self) -> (Vector<V>, impl Stream<Item = Vec<VectorDiff<V>>>) {
193193
let values: Vector<V> = self.0.values().cloned().collect();
194-
let stream = stream::iter(vec![values.clone()]).map(|v| vec![VectorDiff::Reset{ values: v }]);
194+
let stream =
195+
stream::iter(vec![values.clone()]).map(|v| vec![VectorDiff::Reset { values: v }]);
195196
(values, stream)
196197
}
197198
}

crates/matrix-sdk-base/src/store/traits.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::{
2323
use as_variant::as_variant;
2424
use async_trait::async_trait;
2525
use growable_bloom_filter::GrowableBloom;
26+
use matrix_sdk_common::AsyncTraitDeps;
2627
use ruma::{
2728
api::MatrixVersion,
2829
events::{
@@ -49,8 +50,9 @@ use crate::{
4950

5051
/// An abstract state store trait that can be used to implement different stores
5152
/// for the SDK.
52-
#[async_trait]
53-
pub trait StateStore: fmt::Debug + Send + Sync {
53+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
54+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
55+
pub trait StateStore: AsyncTraitDeps {
5456
/// The error type used by this state store.
5557
type Error: fmt::Debug + Into<StoreError> + From<serde_json::Error>;
5658

@@ -450,7 +452,8 @@ impl<T: fmt::Debug> fmt::Debug for EraseStateStoreError<T> {
450452
}
451453
}
452454

453-
#[async_trait]
455+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
456+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
454457
impl<T: StateStore> StateStore for EraseStateStoreError<T> {
455458
type Error = StoreError;
456459

crates/matrix-sdk-common/src/executor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ use std::{
2020
task::{Context, Poll},
2121
};
2222

23-
use futures_util::FutureExt;
2423
#[cfg(target_arch = "wasm32")]
2524
pub use futures_util::future::Aborted as JoinError;
2625
#[cfg(target_arch = "wasm32")]
2726
use futures_util::future::{AbortHandle, Abortable, RemoteHandle};
27+
use futures_util::FutureExt;
2828
#[cfg(not(target_arch = "wasm32"))]
2929
pub use tokio::task::{spawn, JoinError, JoinHandle};
3030

31-
3231
/// A `Box::pin` future that is `Send` on non-wasm, and without `Send` on wasm.
3332
#[cfg(target_arch = "wasm32")]
3433
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>;
3534
#[cfg(not(target_arch = "wasm32"))]
3635
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
3736

38-
3937
#[cfg(target_arch = "wasm32")]
4038
pub fn spawn<F, T>(future: F) -> JoinHandle<T>
4139
where

crates/matrix-sdk-crypto/src/store/memorystore.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ impl MemoryStore {
194194

195195
type Result<T> = std::result::Result<T, Infallible>;
196196

197-
#[async_trait]
197+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
198+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
198199
impl CryptoStore for MemoryStore {
199200
type Error = Infallible;
200201

crates/matrix-sdk-crypto/src/store/traits.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::{collections::HashMap, fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
18+
use matrix_sdk_common::AsyncTraitDeps;
1819
use ruma::{
1920
events::secret::request::SecretName, DeviceId, OwnedDeviceId, RoomId, TransactionId, UserId,
2021
};
@@ -36,8 +37,9 @@ use crate::{
3637

3738
/// Represents a store that the `OlmMachine` uses to store E2EE data (such as
3839
/// cryptographic keys).
39-
#[async_trait]
40-
pub trait CryptoStore: fmt::Debug + Send + Sync {
40+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
41+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
42+
pub trait CryptoStore: AsyncTraitDeps {
4143
/// The error type used by this crypto store.
4244
type Error: fmt::Debug + Into<CryptoStoreError>;
4345

@@ -367,7 +369,8 @@ impl<T: fmt::Debug> fmt::Debug for EraseCryptoStoreError<T> {
367369
}
368370
}
369371

370-
#[async_trait]
372+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
373+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
371374
impl<T: CryptoStore> CryptoStore for EraseCryptoStoreError<T> {
372375
type Error = CryptoStoreError;
373376

crates/matrix-sdk-ui/src/sync_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use eyeball::{SharedObservable, Subscriber};
2929
use futures_core::Future;
3030
use futures_util::{pin_mut, StreamExt as _};
3131
use matrix_sdk::Client;
32-
use thiserror::Error;
3332
use matrix_sdk_base::executor::{spawn, JoinHandle};
33+
use thiserror::Error;
3434
use tokio::sync::{
3535
mpsc::{Receiver, Sender},
3636
Mutex as AsyncMutex, OwnedMutexGuard,

crates/matrix-sdk-ui/src/timeline/pinned_events_loader.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ use std::{fmt::Formatter, sync::Arc};
1616

1717
use futures_util::{stream, StreamExt};
1818
use matrix_sdk::{
19-
config::RequestConfig, event_cache::paginator::PaginatorError, executor::{BoxFuture, BoxFutureExt}, Room,
19+
config::RequestConfig,
20+
event_cache::paginator::PaginatorError,
21+
executor::{BoxFuture, BoxFutureExt},
22+
Room,
2023
};
2124
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
2225
use ruma::{events::relation::RelationType, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId};

crates/matrix-sdk-ui/src/timeline/tests/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ use futures_util::FutureExt as _;
2727
use indexmap::IndexMap;
2828
use matrix_sdk::{
2929
config::RequestConfig,
30-
deserialized_responses::{SyncTimelineEvent, TimelineEvent},
31-
event_cache::paginator::{PaginableRoom, PaginatorError},
32-
executor::{BoxFuture, BoxFutureExt},
33-
room::{EventWithContextResponse, Messages, MessagesOptions},
34-
send_queue::RoomSendQueueUpdate,
30+
deserialized_responses::{SyncTimelineEvent, TimelineEvent},
31+
event_cache::paginator::{PaginableRoom, PaginatorError},
32+
executor::{BoxFuture, BoxFutureExt},
33+
room::{EventWithContextResponse, Messages, MessagesOptions},
34+
send_queue::RoomSendQueueUpdate,
3535
test_utils::events::EventFactory,
3636
};
3737
use matrix_sdk_base::{latest_event::LatestEvent, RoomInfo, RoomState};

crates/matrix-sdk-ui/src/timeline/traits.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use indexmap::IndexMap;
1919
#[cfg(test)]
2020
use matrix_sdk::crypto::{DecryptionSettings, TrustRequirement};
2121
use matrix_sdk::{
22-
deserialized_responses::TimelineEvent,
23-
event_cache::paginator::PaginableRoom,
24-
executor::{BoxFuture, BoxFutureExt as _},
25-
AsyncTraitDeps, Result, Room
22+
deserialized_responses::TimelineEvent,
23+
event_cache::paginator::PaginableRoom,
24+
executor::{BoxFuture, BoxFutureExt as _},
25+
Result, Room, SendOutsideWasm, SyncOutsideWasm,
2626
};
2727
use matrix_sdk_base::{latest_event::LatestEvent, RoomInfo};
2828
use ruma::{
@@ -49,8 +49,8 @@ pub trait RoomExt {
4949
///
5050
/// This is the same as using `room.timeline_builder().build()`.
5151
#[cfg(not(target_arch = "wasm32"))]
52-
fn timeline(&self) -> impl Future<Output = Result<Timeline, timeline::Error>> + Send;
53-
52+
fn timeline(&self) -> impl Future<Output = Result<Timeline, timeline::Error>> + Send;
53+
5454
/// Get a [`Timeline`] for this room.
5555
///
5656
/// This offers a higher-level API than event handlers, in treating things
@@ -59,7 +59,7 @@ pub trait RoomExt {
5959
///
6060
/// This is the same as using `room.timeline_builder().build()`.
6161
#[cfg(target_arch = "wasm32")]
62-
fn timeline(&self) -> impl Future<Output = Result<Timeline, timeline::Error>>;
62+
fn timeline(&self) -> impl Future<Output = Result<Timeline, timeline::Error>>;
6363

6464
/// Get a [`TimelineBuilder`] for this room.
6565
///
@@ -82,7 +82,8 @@ impl RoomExt for Room {
8282
}
8383
}
8484

85-
pub(super) trait RoomDataProvider: AsyncTraitDeps + Clone + 'static + PaginableRoom + PinnedEventsRoom
85+
pub(super) trait RoomDataProvider:
86+
Clone + SendOutsideWasm + SyncOutsideWasm + 'static + PaginableRoom + PinnedEventsRoom
8687
{
8788
fn own_user_id(&self) -> &UserId;
8889
fn room_version(&self) -> RoomVersionId;
@@ -294,8 +295,7 @@ impl RoomDataProvider for Room {
294295

295296
// Internal helper to make most of retry_event_decryption independent of a room
296297
// object, which is annoying to create for testing and not really needed
297-
pub(super) trait Decryptor: Clone + AsyncTraitDeps + 'static {
298-
298+
pub(super) trait Decryptor: Clone + SendOutsideWasm + SyncOutsideWasm + 'static {
299299
#[cfg(not(target_arch = "wasm32"))]
300300
fn decrypt_event_impl(
301301
&self,

crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ use std::{
2525
};
2626

2727
use growable_bloom_filter::{GrowableBloom, GrowableBloomBuilder};
28-
use matrix_sdk::{crypto::types::events::UtdCause, Client};
29-
use matrix_sdk::executor::{spawn, JoinHandle};
28+
use matrix_sdk::{
29+
crypto::types::events::UtdCause,
30+
executor::{spawn, JoinHandle},
31+
Client,
32+
};
3033
use matrix_sdk_base::{StateStoreDataKey, StateStoreDataValue, StoreError};
3134
use ruma::{EventId, OwnedEventId};
3235
use tokio::{

crates/matrix-sdk/src/event_handler/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ use std::{
3939
future::Future,
4040
pin::Pin,
4141
sync::{
42-
atomic::{AtomicU64, Ordering::SeqCst}, RwLock
42+
atomic::{AtomicU64, Ordering::SeqCst},
43+
RwLock,
4344
},
4445
};
4546

crates/matrix-sdk/src/sliding_sync/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Sliding Sync errors.
22
3-
use thiserror::Error;
43
use matrix_sdk_common::executor::JoinError;
4+
use thiserror::Error;
55

66
/// Internal representation of errors in Sliding Sync.
77
#[derive(Error, Debug)]

crates/matrix-sdk/src/sliding_sync/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ use async_stream::stream;
3535
pub use client::{Version, VersionBuilder};
3636
use futures_core::stream::Stream;
3737
pub use matrix_sdk_base::sliding_sync::http;
38-
use matrix_sdk_common::{executor::spawn, timer};
3938
#[cfg(feature = "e2e-encryption")]
4039
use matrix_sdk_common::executor::JoinHandleExt as _;
41-
40+
use matrix_sdk_common::{executor::spawn, timer};
4241
use ruma::{
4342
api::{client::error::ErrorKind, OutgoingRequest},
4443
assign, OwnedEventId, OwnedRoomId, RoomId,

0 commit comments

Comments
 (0)